A3: keep gutter change markers on their line when text is inserted at its start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-10-31 14:25:47 +01:00
parent 983319d8a3
commit ce681871ad
2 changed files with 8 additions and 0 deletions

View file

@ -108,6 +108,12 @@ class GitMarker extends GutterMarker {
super(); super();
} }
/** Text inserted at the line's start pushes the marker down with the line. */
override startSide = 1;
/** Same side as the start, so the empty range survives mapping. */
override endSide = 1;
override eq(other: GutterMarker): boolean { override eq(other: GutterMarker): boolean {
return other instanceof GitMarker && other.kind === this.kind; return other instanceof GitMarker && other.kind === this.kind;
} }

View file

@ -220,6 +220,8 @@ describe("the gutter", () => {
expect(markers(view)).toEqual({ 2: "modified" }); expect(markers(view)).toEqual({ 2: "modified" });
view.dispatch({ changes: { from: 0, insert: "new\n" } }); view.dispatch({ changes: { from: 0, insert: "new\n" } });
expect(markers(view)).toEqual({ 3: "modified" }); expect(markers(view)).toEqual({ 3: "modified" });
view.dispatch({ changes: { from: view.state.doc.line(3).from, insert: "typed\n" } });
expect(markers(view)).toEqual({ 4: "modified" });
engine.answer = { ranges: [], version: 2 }; engine.answer = { ranges: [], version: 2 };
refreshGitGutters(); refreshGitGutters();
await flush(); await flush();