fixed highlighting issue
This commit is contained in:
parent
9bcaaa3ac4
commit
87e723649e
1 changed files with 1 additions and 3 deletions
|
|
@ -25,7 +25,6 @@ const miniLocations = StateField.define({
|
||||||
//block-based eval case
|
//block-based eval case
|
||||||
if (e.value.range) {
|
if (e.value.range) {
|
||||||
const stateMiniLocations = getMiniLocationsFromDecorations(locations);
|
const stateMiniLocations = getMiniLocationsFromDecorations(locations);
|
||||||
const existingById = new Map(stateMiniLocations.map(({ id, from, to }) => [id, [from, to]]));
|
|
||||||
|
|
||||||
const normalized = e.value.locations
|
const normalized = e.value.locations
|
||||||
.filter(([from]) => from < tr.newDoc.length)
|
.filter(([from]) => from < tr.newDoc.length)
|
||||||
|
|
@ -35,13 +34,12 @@ const miniLocations = StateField.define({
|
||||||
|
|
||||||
const marks = normalized.map((range) => {
|
const marks = normalized.map((range) => {
|
||||||
const id = range.join(':');
|
const id = range.join(':');
|
||||||
const useRange = existingById.get(id) || range;
|
|
||||||
return Decoration.mark({
|
return Decoration.mark({
|
||||||
id,
|
id,
|
||||||
// this green is only to verify that the decoration moves when the document is edited
|
// this green is only to verify that the decoration moves when the document is edited
|
||||||
// it will be removed later, so the mark is not visible by default
|
// it will be removed later, so the mark is not visible by default
|
||||||
attributes: { style: `background-color: #00CA2880` },
|
attributes: { style: `background-color: #00CA2880` },
|
||||||
}).range(...useRange); // -> Decoration
|
}).range(...range); // -> Decoration
|
||||||
});
|
});
|
||||||
|
|
||||||
const previousMarks = stateMiniLocations
|
const previousMarks = stateMiniLocations
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue