Elffuss BraidHub

kikocis/continue public

fix: next edit renders that should render decorations will render them properly (#7160)

* fix: passing next edit requests will render things

* chore: remove comment

* feat: skip whitespace only deletions

* feat: add a utility function for checking if a diff is a whitespace only deletion

* feat: add test for next edit utils

* feat: move filtering to NextEditProvider

* fix: escape newline properly

* feat: make jump decoration more visible

* feat: remove redundant escapes

* fix: undo the escapeSVG

* fix: update tests

* fix: use proper line heights

* fix: place the SVG at the end of the line

* fix: handle cases where the completion is a single line

* feat: improve next edit UI (#7167)

* fix: use proper line heights

* fix: place the SVG at the end of the line

* fix: handle cases where the completion is a single line

* fix: allocate more memory for the GUI build step

* fix: set flag as node options

* fix: jump scrolls only after accepting

* fix: update jump manager vitest
Changeset935a14819b15637cacfdd84a5f27ab64b28e5a098bcee56675839a88d08ccad1
AuthorJacob Kim <jacob@continue.dev> · 2025-08-15 12:18 -07:00
CommitterGitHub <noreply@github.com> · 2025-08-15 15:18 -04:00
Parentse8c57a7b5386

Browse the files at this changeset

8 files changed

modified .github/actions/build-vscode-extension/action.yml +4 −2
@@ -105,7 +105,9 @@
105105 shell: bash
106106 run: |
107107 cd gui
108- npm run build
108+ npm run build --max-old-space-size=4096
109+ env:
110+ NODE_OPTIONS: "--max-old-space-size=4096"
109111
110112 - name: Prepackage the extension
111113 shell: bash
@@ -156,4 +158,4 @@
156158 npx vsce package --pre-release --no-dependencies --target ${{ steps.set-target.outputs.target }}
157159 else
158160 npx vsce package --no-dependencies --target ${{ steps.set-target.outputs.target }}
159- fi
No newline at the end of the file
161+ fi
modified core/codeRenderer/CodeRenderer.ts +36 −16
@@ -243,7 +243,10 @@
243243 );
244244 const backgroundColor = this.getBackgroundColor(highlightedCodeHtml);
245245
246- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${options.dimensions.width}" height="${options.dimensions.height}" shape-rendering="crispEdges">
246+ const lines = code.split("\n");
247+ const actualHeight = lines.length * options.lineHeight;
248+
249+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${options.dimensions.width}" height="${actualHeight}" shape-rendering="crispEdges">
247250 <style>
248251 :root {
249252 --purple: rgb(112, 114, 209);
@@ -252,7 +255,7 @@
252255 }
253256 </style>
254257 <g>
255- <rect x="0" y="0" rx="10" ry="10" width="${options.dimensions.width}" height="${options.dimensions.height}" fill="${this.editorBackground}" shape-rendering="crispEdges" />
258+ <rect x="0" y="0" rx="10" ry="10" width="${options.dimensions.width}" height="${actualHeight}" fill="${this.editorBackground}" shape-rendering="crispEdges" />
256259 ${lineBackgrounds}
257260 ${guts}
258261 </g>
@@ -317,29 +320,46 @@
317320 const y = index * options.lineHeight;
318321 const isFirst = index === 0;
319322 const isLast = index === lines.length - 1;
323+ const isSingleLine = isFirst && isLast;
320324 const radius = 10;
325+
326+ // Handle single line case (both first and last)
327+ if (isSingleLine) {
328+ return `<path d="M ${radius} ${y}
329+ L ${options.dimensions.width - radius} ${y}
330+ Q ${options.dimensions.width} ${y} ${options.dimensions.width} ${y + radius}
331+ L ${options.dimensions.width} ${y + options.lineHeight - radius}
332+ Q ${options.dimensions.width} ${y + options.lineHeight} ${options.dimensions.width - radius} ${y + options.lineHeight}
333+ L ${radius} ${y + options.lineHeight}
334+ Q ${0} ${y + options.lineHeight} ${0} ${y + options.lineHeight - radius}
335+ L ${0} ${y + radius}
336+ Q ${0} ${y} ${radius} ${y}
337+ Z"
338+ fill="${bgColor}" />`;
339+ }
340+
321341 // SVG notes:
322342 // By default SVGs have anti-aliasing on.
323343 // This is undesirable in our case because pixel-perfect alignment of these rectangles will introduce thin gaps.
324344 // Turning it off with 'shape-rendering="crispEdges"' solves the issue.
325345 return isFirst
326346 ? `<path d="M ${0} ${y + options.lineHeight}
327- L ${0} ${y + radius}
328- Q ${0} ${y} ${radius} ${y}
329- L ${options.dimensions.width - radius} ${y}
330- Q ${options.dimensions.width} ${y} ${options.dimensions.width} ${y + radius}
331- L ${options.dimensions.width} ${y + options.lineHeight}
332- Z"
333- fill="${bgColor}" />`
347+ L ${0} ${y + radius}
348+ Q ${0} ${y} ${radius} ${y}
349+ L ${options.dimensions.width - radius} ${y}
350+ Q ${options.dimensions.width} ${y} ${options.dimensions.width} ${y + radius}
351+ L ${options.dimensions.width} ${y + options.lineHeight}
352+ Z"
353+ fill="${bgColor}" />`
334354 : isLast
335355 ? `<path d="M ${0} ${y}
336- L ${0} ${y + options.lineHeight - radius}
337- Q ${0} ${y + options.lineHeight} ${radius} ${y + options.lineHeight}
338- L ${options.dimensions.width - radius} ${y + options.lineHeight}
339- Q ${options.dimensions.width} ${y + options.lineHeight} ${options.dimensions.width} ${y + options.lineHeight - 10}
340- L ${options.dimensions.width} ${y}
341- Z"
342- fill="${bgColor}" />`
356+ L ${0} ${y + options.lineHeight - radius}
357+ Q ${0} ${y + options.lineHeight} ${radius} ${y + options.lineHeight}
358+ L ${options.dimensions.width - radius} ${y + options.lineHeight}
359+ Q ${options.dimensions.width} ${y + options.lineHeight} ${options.dimensions.width} ${y + options.lineHeight - 10}
360+ L ${options.dimensions.width} ${y}
361+ Z"
362+ fill="${bgColor}" />`
343363 : `<rect x="0" y="${y}" width="100%" height="${options.lineHeight}" fill="${bgColor}" shape-rendering="crispEdges" />`;
344364 })
345365 .join("\n");
modified core/nextEdit/NextEditProvider.ts +28 −21
@@ -33,7 +33,6 @@
3333 import { modelSupportsNextEdit } from "../llm/autodetect.js";
3434 import { countTokens } from "../llm/countTokens.js";
3535 import { localPathOrUriToPath } from "../util/pathToUri.js";
36-import { replaceEscapedCharacters } from "../util/text.js";
3736 import {
3837 INSTINCT_SYSTEM_PROMPT,
3938 MERCURY_CODE_TO_EDIT_OPEN,
@@ -60,6 +59,7 @@
6059 PromptMetadata,
6160 RecentlyEditedRange,
6261 } from "./types.js";
62+import { isWhitespaceOnlyDeletion } from "./utils.js";
6363
6464 const autocompleteCache = AutocompleteLruCache.get();
6565
@@ -685,13 +685,17 @@
685685 return undefined;
686686 }
687687
688- const nextCompletion = msg.content.split(
689- `${MERCURY_CODE_TO_EDIT_OPEN}\n`,
690- )[1]
691- ? replaceEscapedCharacters(
692- msg.content.split(`${MERCURY_CODE_TO_EDIT_OPEN}\n`)[1],
693- ).replace(/\n$/, "")
694- : replaceEscapedCharacters(msg.content);
688+ // const nextCompletion = msg.content.split(
689+ // `${MERCURY_CODE_TO_EDIT_OPEN}\n`,
690+ // )[1]
691+ // ? replaceEscapedCharacters(
692+ // msg.content.split(`${MERCURY_CODE_TO_EDIT_OPEN}\n`)[1],
693+ // ).replace(/\n$/, "")
694+ // : replaceEscapedCharacters(msg.content);
695+ const nextCompletion =
696+ msg.content
697+ .split(`${MERCURY_CODE_TO_EDIT_OPEN}\n`)[1]
698+ .replace(/\n$/, "") ?? msg.content;
695699
696700 if (opts?.usingFullFileDiff === false || !opts?.usingFullFileDiff) {
697701 return await this._handlePartialFileDiff(
@@ -773,13 +777,16 @@
773777 .slice(editableRegionStartLine, editableRegionEndLine + 1)
774778 .join("\n");
775779 const diffLines = myersDiff(fileSlice, nextCompletion);
776- const diffGroups = groupDiffLines(diffLines, editableRegionStartLine, 5);
780+ const diffGroups = groupDiffLines(
781+ diffLines,
782+ editableRegionStartLine,
783+ 5,
784+ ).filter((group) => !isWhitespaceOnlyDeletion(group.lines));
777785 const currentLine = helper.pos.line;
778- let cursorLocalDiffGroup: DiffGroup | undefined;
779786 const prefetchQueue = PrefetchQueue.getInstance();
780787
781788 // Process diff groups and find the one containing the cursor
782- await this._processDiffGroups(
789+ const cursorLocalDiffGroup = await this._processDiffGroups(
783790 diffGroups,
784791 currentLine,
785792 helper,
@@ -798,16 +805,16 @@
798805 helper.input.completionId,
799806 true,
800807 );
801- } else if (diffGroups.length > 0) {
802- // Fallback to first diff group if cursor's group not found
803- return await this._createOutcomeFromDiffGroup(
804- diffGroups[0],
805- helper,
806- startTime,
807- llm,
808- helper.input.completionId,
809- false,
810- );
808+ // } else if (diffGroups.length > 0) {
809+ // // Fallback to first diff group if cursor's group not found
810+ // return await this._createOutcomeFromDiffGroup(
811+ // diffGroups[0],
812+ // helper,
813+ // startTime,
814+ // llm,
815+ // helper.input.completionId,
816+ // false,
817+ // );
811818 }
812819
813820 return undefined;
modified core/nextEdit/utils.ts +10 −0
@@ -1,3 +1,5 @@
1+import { DiffLine } from "..";
2+
13 export function isNextEditTest(): boolean {
24 const enabled = process.env.NEXT_EDIT_TEST_ENABLED;
35
@@ -11,3 +13,11 @@
1113
1214 return false;
1315 }
16+
17+export function isWhitespaceOnlyDeletion(diffLines: DiffLine[]): boolean {
18+ return diffLines.every(
19+ (diff) =>
20+ diff.type === "old" &&
21+ (diff.line.trim() === "" || /^\s+$/.test(diff.line)),
22+ );
23+}
added core/nextEdit/utils.vitest.ts +59 −0
@@ -0,0 +1,59 @@
1+import { describe, expect, test, vi } from "vitest";
2+import { DiffLine } from "..";
3+import { isNextEditTest, isWhitespaceOnlyDeletion } from "./utils";
4+
5+describe("isNextEditTest", () => {
6+ test("returns true when NEXT_EDIT_TEST_ENABLED is 'true'", () => {
7+ vi.stubEnv("NEXT_EDIT_TEST_ENABLED", "true");
8+ expect(isNextEditTest()).toBe(true);
9+ });
10+
11+ test("returns false when NEXT_EDIT_TEST_ENABLED is 'false'", () => {
12+ vi.stubEnv("NEXT_EDIT_TEST_ENABLED", "false");
13+ expect(isNextEditTest()).toBe(false);
14+ });
15+
16+ test("returns false when NEXT_EDIT_TEST_ENABLED is undefined", () => {
17+ vi.stubEnv("NEXT_EDIT_TEST_ENABLED", undefined);
18+ expect(isNextEditTest()).toBe(false);
19+ });
20+});
21+
22+describe("isWhitespaceOnlyDeletion", () => {
23+ test("returns true for whitespace-only deletions", () => {
24+ const diffLines: DiffLine[] = [
25+ { type: "old", line: " " },
26+ { type: "old", line: "\t" },
27+ ];
28+ expect(isWhitespaceOnlyDeletion(diffLines)).toBe(true);
29+ });
30+
31+ test("returns false for non-whitespace deletions", () => {
32+ const diffLines: DiffLine[] = [
33+ { type: "old", line: "code" },
34+ { type: "old", line: " " },
35+ ];
36+ expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
37+ });
38+
39+ test("returns false for mixed content", () => {
40+ const diffLines: DiffLine[] = [
41+ { type: "old", line: " " },
42+ { type: "old", line: "code" },
43+ ];
44+ expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
45+ });
46+
47+ test("returns false for mixed type", () => {
48+ const diffLines: DiffLine[] = [
49+ { type: "old", line: " " },
50+ { type: "new", line: "" },
51+ ];
52+ expect(isWhitespaceOnlyDeletion(diffLines)).toBe(false);
53+ });
54+
55+ test("returns true for empty array", () => {
56+ const diffLines: DiffLine[] = [];
57+ expect(isWhitespaceOnlyDeletion(diffLines)).toBe(true);
58+ });
59+});
modified extensions/vscode/src/activation/JumpManager.ts +143 −21
@@ -1,11 +1,65 @@
11 import { NextEditProvider } from "core/nextEdit/NextEditProvider";
22 import { NextEditOutcome } from "core/nextEdit/types";
3+// @ts-ignore
4+import svgBuilder from "svg-builder";
35 import * as vscode from "vscode";
6+import { getTheme } from "../util/getTheme";
47 import {
58 HandlerPriority,
69 SelectionChangeManager,
710 } from "./SelectionChangeManager";
811
12+// Instead of getters that execute immediately, use methods or lazy properties
13+const SVG_CONFIG = {
14+ stroke: "#999998",
15+ strokeWidth: 1,
16+ shortcutColor: "#999998",
17+ filter: "drop-shadow(0 2px 2px rgba(0,0,0,0.2))",
18+ radius: 3,
19+ leftMargin: 40,
20+ debounceDelay: 500,
21+ label: "📍 Press Tab to jump, Esc to cancel",
22+
23+ // Convert getters to methods that are called when needed
24+ getFontSize(): number {
25+ return Math.ceil(
26+ (vscode.workspace.getConfiguration("editor").get<number>("fontSize") ??
27+ 14) * 0.8,
28+ );
29+ },
30+
31+ getFontFamily(): string {
32+ return (
33+ vscode.workspace.getConfiguration("editor").get<string>("fontFamily") ||
34+ "helvetica"
35+ );
36+ },
37+
38+ getPaddingX(): number {
39+ return Math.ceil(this.getEstimatedTextWidth(" "));
40+ },
41+
42+ getGap(): number {
43+ return this.getFontSize() * 0.5;
44+ },
45+
46+ getTipWidth(): number {
47+ return this.getEstimatedTextWidth(this.label) + this.getPaddingX();
48+ },
49+
50+ getTipHeight(): number {
51+ return this.getFontSize();
52+ },
53+
54+ getTextY(): number {
55+ return (this.getTipHeight() + this.getFontSize()) / 2;
56+ },
57+
58+ getEstimatedTextWidth(text: string): number {
59+ return text.length * this.getFontSize() * 0.6;
60+ },
61+} as const;
62+
963 export interface CompletionDataForAfterJump {
1064 completionId: string;
1165 outcome: NextEditOutcome;
@@ -16,16 +70,29 @@
1670 private static _instance: JumpManager | undefined;
1771
1872 // Decoration state.
73+ private _jumpIcon: vscode.Uri | undefined;
1974 private _jumpDecoration: vscode.TextEditorDecorationType | undefined;
2075 private _jumpDecorationVisible = false;
2176 private _disposables: vscode.Disposable[] = [];
77+ private _theme = getTheme();
2278
2379 private _jumpInProgress: boolean = false;
2480 private _jumpAccepted: boolean = false;
2581 private _completionAfterJump: CompletionDataForAfterJump | null = null;
2682 private _oldCursorPosition: vscode.Position | undefined;
2783
28- private constructor() {}
84+ private constructor() {
85+ // Build the first SVG icon
86+ this._createSvgJumpIcon();
87+
88+ // Re‑build when the colour theme changes
89+ vscode.workspace.onDidChangeConfiguration((e) => {
90+ if (e.affectsConfiguration("workbench.colorTheme")) {
91+ this._theme = getTheme();
92+ this._createSvgJumpIcon();
93+ }
94+ });
95+ }
2996
3097 initialize() {}
3198
@@ -51,6 +118,62 @@
51118 this._disposables = [];
52119 }
53120
121+ private _createSvgJumpIcon() {
122+ // if (!this._theme) {
123+ // return;
124+ // }
125+
126+ const baseTextConfig = {
127+ y: SVG_CONFIG.getTextY(),
128+ "font-family": SVG_CONFIG.getFontFamily(),
129+ "font-size": SVG_CONFIG.getFontSize(),
130+ };
131+
132+ try {
133+ const svgContent = svgBuilder
134+ .width(SVG_CONFIG.getTipWidth())
135+ .height(SVG_CONFIG.getTipHeight())
136+ .text(
137+ {
138+ ...baseTextConfig,
139+ x: 4,
140+ fill: this._theme?.colors["editor.foreground"] ?? SVG_CONFIG.stroke,
141+ },
142+ SVG_CONFIG.label,
143+ )
144+ .render();
145+
146+ const dataUri = `data:image/svg+xml;base64,${Buffer.from(
147+ svgContent,
148+ ).toString("base64")}`;
149+ this._jumpIcon = vscode.Uri.parse(dataUri);
150+
151+ // Dispose the old decoration (if any) and create a fresh one.
152+ if (this._jumpDecoration) {
153+ this._jumpDecoration.dispose();
154+ }
155+ this._jumpDecoration = this._createSvgJumpDecoration();
156+ } catch (err) {
157+ console.error("Error creating SVG jump tooltip:", err);
158+ }
159+ }
160+
161+ private _createSvgJumpDecoration(): vscode.TextEditorDecorationType {
162+ const backgroundColour =
163+ this._theme?.colors["editor.background"] ?? "#333333";
164+
165+ return vscode.window.createTextEditorDecorationType({
166+ after: {
167+ contentIconPath: this._jumpIcon,
168+ border: `;box-shadow: inset 0 0 0 ${SVG_CONFIG.strokeWidth}px ${SVG_CONFIG.stroke}, inset 0 0 0 ${SVG_CONFIG.getTipHeight()}px ${backgroundColour};
169+ border-radius: ${SVG_CONFIG.radius}px;
170+ filter: ${SVG_CONFIG.filter}`,
171+ margin: `0 0 0 ${SVG_CONFIG.leftMargin}px`,
172+ width: `${SVG_CONFIG.getTipWidth()}px`,
173+ },
174+ });
175+ }
176+
54177 public async suggestJump(
55178 currentPosition: vscode.Position,
56179 nextJumpLocation: vscode.Position,
@@ -157,17 +280,6 @@
157280 );
158281 }
159282
160- // Scroll to show the jump location.
161- editor.revealRange(
162- new vscode.Range(decorationLine, 0, decorationLine, 0),
163- vscode.TextEditorRevealType.InCenter,
164- );
165-
166- // Clean up after timeout if no jump has been made.
167- // setTimeout(() => {
168- // this._jumpInProgress = false;
169- // }, 10000);
170-
171283 return true;
172284 }
173285
@@ -180,18 +292,22 @@
180292 await this.clearJumpDecoration();
181293
182294 // Create a decoration for jump.
183- this._jumpDecoration = vscode.window.createTextEditorDecorationType({
184- before: {
185- contentText: "📍 Press Tab to jump, Esc to cancel",
186- color: new vscode.ThemeColor("editor.foreground"),
187- backgroundColor: new vscode.ThemeColor("editorInfo.background"),
188- margin: `0 0 0 4px`,
189- },
190- });
295+ // this._jumpDecoration = vscode.window.createTextEditorDecorationType({
296+ // before: {
297+ // contentText: "📍 Press Tab to jump, Esc to cancel",
298+ // color: new vscode.ThemeColor("editor.foreground"),
299+ // backgroundColor: new vscode.ThemeColor("editorHover.background"),
300+ // margin: `0 0 0 4px`,
301+ // },
302+ // });
303+
304+ if (!this._jumpDecoration) {
305+ this._createSvgJumpIcon(); // makes both the icon & decoration
306+ }
191307
192308 // Apply the decoration.
193309 const lastIndexOfLine = editor.document.lineAt(lineToRenderOn).text.length;
194- editor.setDecorations(this._jumpDecoration, [
310+ editor.setDecorations(this._jumpDecoration!, [
195311 new vscode.Range(
196312 lineToRenderOn,
197313 lastIndexOfLine,
@@ -240,6 +356,12 @@
240356 if (this._jumpDecorationVisible) {
241357 this._jumpAccepted = true;
242358
359+ // Scroll to show the jump location.
360+ editor.revealRange(
361+ new vscode.Range(jumpPosition.line, 0, jumpPosition.line, 0),
362+ vscode.TextEditorRevealType.InCenter,
363+ );
364+
243365 // Move cursor to the jump position.
244366 editor.selection = new vscode.Selection(jumpPosition, jumpPosition);
245367 await this.clearJumpDecoration();
modified extensions/vscode/src/activation/JumpManager.vitest.ts +90 −13
@@ -36,6 +36,21 @@
3636 dispose: vi.fn(),
3737 }),
3838 },
39+ workspace: {
40+ getConfiguration: vi.fn().mockImplementation((section?: string) => {
41+ // Return a configuration object with a get method
42+ return {
43+ get: vi.fn().mockImplementation((key: string) => {
44+ if (key === "fontSize") return 14;
45+ if (key === "fontFamily") return "monaco";
46+ return undefined;
47+ }),
48+ };
49+ }),
50+ onDidChangeConfiguration: vi.fn().mockReturnValue({
51+ dispose: vi.fn(),
52+ }),
53+ },
3954 Position: class {
4055 constructor(
4156 public line: number,
@@ -69,6 +84,32 @@
6984 dispose: vi.fn(),
7085 }),
7186 },
87+ Uri: {
88+ parse: vi.fn().mockReturnValue({ toString: () => "mock-uri" }),
89+ },
90+ };
91+});
92+
93+// Mock getTheme utility
94+vi.mock("../util/getTheme", () => ({
95+ getTheme: vi.fn().mockReturnValue({
96+ colors: {
97+ "editor.foreground": "#ffffff",
98+ "editor.background": "#1e1e1e",
99+ },
100+ }),
101+}));
102+
103+// Mock svg-builder
104+vi.mock("svg-builder", () => {
105+ const mockSvgBuilder = {
106+ width: vi.fn().mockReturnThis(),
107+ height: vi.fn().mockReturnThis(),
108+ text: vi.fn().mockReturnThis(),
109+ render: vi.fn().mockReturnValue("<svg>mock svg</svg>"),
110+ };
111+ return {
112+ default: mockSvgBuilder,
72113 };
73114 });
74115
@@ -152,20 +193,32 @@
152193 let jumpManager: JumpManager;
153194
154195 beforeEach(() => {
155- // Reset mocks
156- vi.resetAllMocks();
157-
158- // Re-setup the lineAt mock after reset
159- const mockLineAt = vi.fn().mockReturnValue({
160- text: "Sample line text",
161- lineNumber: 0,
196+ // Clear mock history but keep implementations
197+ vi.clearAllMocks();
198+
199+ // Create a proper TextLine mock
200+ const createMockTextLine = (text: string, lineNumber: number) => ({
201+ text,
202+ lineNumber,
203+ range: new vscode.Range(lineNumber, 0, lineNumber, text.length),
204+ rangeIncludingLineBreak: new vscode.Range(
205+ lineNumber,
206+ 0,
207+ lineNumber + 1,
208+ 0,
209+ ),
210+ firstNonWhitespaceCharacterIndex: text.search(/\S/),
211+ isEmptyOrWhitespace: text.trim().length === 0,
162212 });
163213
164- // Ensure our mock is properly set up after reset
165- if (vscode.window.activeTextEditor?.document) {
214+ // Reset lineAt mock with proper TextLine objects
215+ if (vscode.window.activeTextEditor?.document.lineAt) {
166216 vi.mocked(
167217 vscode.window.activeTextEditor.document.lineAt,
168- ).mockImplementation(mockLineAt);
218+ // @ts-ignore
219+ ).mockImplementation((line: number) =>
220+ createMockTextLine("Sample line text", line),
221+ );
169222 }
170223
171224 // Clear any existing instance
@@ -240,7 +293,7 @@
240293 // Decorations should not be created
241294 expect(
242295 vscode.window.createTextEditorDecorationType,
243- ).not.toHaveBeenCalled();
296+ ).toHaveBeenCalledOnce(); // only during setup
244297 });
245298
246299 it("should render decoration for jump location outside visible range (below)", async () => {
@@ -293,8 +346,32 @@
293346
294347 // Should create decoration
295348 expect(vscode.window.createTextEditorDecorationType).toHaveBeenCalled();
296- // Should reveal range
297- expect(vscode.window.activeTextEditor!.revealRange).toHaveBeenCalled();
349+ // Should not reveal range
350+ expect(
351+ vscode.window.activeTextEditor!.revealRange,
352+ ).not.toHaveBeenCalled();
353+ });
354+
355+ it("should call revealRange when jump is accepted", async () => {
356+ const currentPosition = new vscode.Position(1, 0);
357+ const nextJumpLocation = new vscode.Position(8, 0); // Outside visible range
358+
359+ await jumpManager.suggestJump(currentPosition, nextJumpLocation);
360+
361+ // Find the acceptJump command handler.
362+ const commandArgs = vi
363+ .mocked(vscode.commands.registerCommand)
364+ .mock.calls.find((call: any) => call[0] === "continue.acceptJump");
365+ expect(commandArgs).toBeDefined();
366+ const acceptJumpHandler = commandArgs![1];
367+
368+ await acceptJumpHandler();
369+
370+ // Should reveal the jump location range after jumping.
371+ expect(vscode.window.activeTextEditor!.revealRange).toHaveBeenCalledWith(
372+ new vscode.Range(nextJumpLocation.line, 0, nextJumpLocation.line, 0),
373+ vscode.TextEditorRevealType.InCenter,
374+ );
298375 });
299376 });
300377
modified extensions/vscode/src/activation/NextEditWindowManager.ts +12 −16
@@ -669,17 +669,9 @@
669669 const offsetFromTop =
670670 (position.line - editableRegionStartLine) * SVG_CONFIG.lineHeight;
671671
672- // Set the margin-left so that it's never covering code inside the editable region.
673- const marginLeft =
674- SVG_CONFIG.getTipWidth(originalCode) -
675- SVG_CONFIG.getTipWidth(originalCode.split("\n")[currLineOffsetFromTop]);
676-
677- // console.log(marginLeft);
678- // console.log(SVG_CONFIG.getTipWidth(originalCode));
679- // console.log(
680- // SVG_CONFIG.getTipWidth(originalCode.split("\n")[currLineOffsetFromTop]),
681- // );
682- // console.log(originalCode.split("\n")[currLineOffsetFromTop]);
672+ // Position the decoration with minimal left margin since it's already at line end
673+ const marginLeft = SVG_CONFIG.paddingX; // Use consistent padding instead of complex calculation
674+
683675 return vscode.window.createTextEditorDecorationType({
684676 before: {
685677 contentIconPath: uri,
@@ -770,12 +762,16 @@
770762 ): vscode.Position {
771763 // Create a position that's offset spaces to the right of the cursor.
772764
765+ // const line = editor.document.lineAt(position.line);
766+ // const offsetChar = Math.min(
767+ // position.character + SVG_CONFIG.cursorOffset,
768+ // line.text.length,
769+ // );
770+ // return new vscode.Position(position.line, offsetChar);
771+
772+ // Place decoration at the end of the current line
773773 const line = editor.document.lineAt(position.line);
774- const offsetChar = Math.min(
775- position.character + SVG_CONFIG.cursorOffset,
776- line.text.length,
777- );
778- return new vscode.Position(position.line, offsetChar);
774+ return new vscode.Position(position.line, line.text.length);
779775 }
780776
781777 /**