Skip to content

Commit

Permalink
Avoid duplicate gutter markers
Browse files Browse the repository at this point in the history
To avoid remote, local and merge diff views adding overlapping gutter markers of the same type on the same line. We leave it to CM to handle multiple markers of different types on the same line, but that shouldn't really apply for us.
  • Loading branch information
vidartf committed Nov 10, 2023
1 parent f914453 commit 33a903a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/nbdime/src/common/mergeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,18 @@ const gutterMarkerField = StateField.define<RangeSet<MergeMarker>>({
: e.value.block
? conflictBlockMarker
: conflictMarker;
gutters = gutters.update({ add: [marker.range(e.value.from)] });
// check for overlap (duplicates) with same type
let overlap = false;
gutters.between(e.value.from, e.value.from, (from, to, value) => {
if (from === e.value.from && value.eq(marker)) {
overlap = true;
return false;
}
return;
});
if (!overlap) {
gutters = gutters.update({ add: [marker.range(e.value.from)] });
}
}
}
if (e.is(removeGutterMarkerEffect)) {
Expand Down

0 comments on commit 33a903a

Please sign in to comment.