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) => {

Check warning on line 337 in packages/nbdime/src/common/mergeview.ts

View check run for this annotation

Codecov / codecov/patch

packages/nbdime/src/common/mergeview.ts#L336-L337

Added lines #L336 - L337 were not covered by tests
if (from === e.value.from && value.eq(marker)) {
overlap = true;
return false;

Check warning on line 340 in packages/nbdime/src/common/mergeview.ts

View check run for this annotation

Codecov / codecov/patch

packages/nbdime/src/common/mergeview.ts#L339-L340

Added lines #L339 - L340 were not covered by tests
}
return;

Check warning on line 342 in packages/nbdime/src/common/mergeview.ts

View check run for this annotation

Codecov / codecov/patch

packages/nbdime/src/common/mergeview.ts#L342

Added line #L342 was not covered by tests
});
if (!overlap) {
gutters = gutters.update({ add: [marker.range(e.value.from)] });

Check warning on line 345 in packages/nbdime/src/common/mergeview.ts

View check run for this annotation

Codecov / codecov/patch

packages/nbdime/src/common/mergeview.ts#L345

Added line #L345 was not covered by tests
}
}
}
if (e.is(removeGutterMarkerEffect)) {
Expand Down

0 comments on commit 33a903a

Please sign in to comment.