Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai de110b5c50 fix(debugger): keep the inlay Run to Cursor button while the pointer moves to it
The button sits left of the line's first non-space character, over the
indent or the gutter, but the hover area started at the text and ended four
characters in: moving the pointer to the button left the area and hid it
before it could be clicked. The area now includes the gutter, and while the
button is shown it reaches the button's right edge on that line.

Fixes #6832
2026-11-29 20:36:42 +08:00
2 змінених файлів з 23 додано та 6 видалено

No files matched your search

+10 -2
Переглянути файл
@@ -7,9 +7,17 @@ describe("inlay Run to Cursor", () => {
expect(hoveredLine(100, 8, 100, line)).toBe(2);
expect(hoveredLine(100, 8, 132, line)).toBe(2);
});
it("ignores the pointer further right, left of the text, and blank lines", () => {
it("counts the gutter left of the text, as the button can sit over it", () => {
expect(hoveredLine(100, 8, 99, line)).toBe(2);
expect(hoveredLine(100, 8, 40, line)).toBe(2);
});
it("ignores the pointer further right and blank lines", () => {
expect(hoveredLine(100, 8, 133, line)).toBeNull();
expect(hoveredLine(100, 8, 99, line)).toBeNull();
expect(hoveredLine(100, 8, 104, { number: 4, text: " " })).toBeNull();
});
it("keeps the line on the way to a button drawn past the first characters (a deep indent)", () => {
const deep = { number: 7, text: " return x" };
expect(hoveredLine(100, 8, 200, deep, 226)).toBe(6);
expect(hoveredLine(100, 8, 227, deep, 226)).toBeNull();
});
});
+13 -4
Переглянути файл
@@ -1,5 +1,5 @@
/**
* Inlay Run to Cursor: while the debugger is paused, hovering the start of a
* Inlay Run to Cursor: while the debugger is paused, hovering the gutter or the start of a
* line shows a small button left of its text that runs to that line (Resume on
* the execution line itself). Settings › Debugger › "Show inlay Run to Cursor popup".
*/
@@ -19,14 +19,19 @@ import styles from "./editor.module.css";
const HOVER_CHARS = 4;
const BUTTON = 20;
/** The 0-based line whose start the pointer is over, or null. */
/**
* The 0-based line whose start the pointer is over, or null: the gutter and the first
* characters of the line. `reach` extends the area to the right edge of the button shown on
* this line, so moving to a button drawn further right (a deep indent) keeps it.
*/
export function hoveredLine(
textLeft: number,
charWidth: number,
x: number,
line: { number: number; text: string },
reach = -Infinity,
): number | null {
if (x < textLeft || x - textLeft > charWidth * HOVER_CHARS) return null;
if (x > Math.max(textLeft + charWidth * HOVER_CHARS, reach)) return null;
return line.text.trim() ? line.number - 1 : null;
}
@@ -60,7 +65,11 @@ export function runToCursorInlay(ctx: EditorDocContext): Extension {
const line = view.state.doc.lineAt(block.from);
const textLeft = view.coordsAtPos(line.from, 1)?.left;
if (textLeft == null) return this.hide();
const target = hoveredLine(textLeft, view.defaultCharacterWidth, e.clientX, line);
// The button sits left of the first non-space character, over the indent or the gutter:
// the way to it stays inside the area.
const shown =
this.button && this.line === line.number - 1 ? this.button.getBoundingClientRect().right : undefined;
const target = hoveredLine(textLeft, view.defaultCharacterWidth, e.clientX, line, shown);
if (target == null) return this.hide();
if (target !== this.line) this.show(target, block.top + view.documentTop, line.from);
};