feat(debugger): Show the value of the selected code while paused (#173)

Settings › Debugger › Data Views gains Show value tooltip on code selection
(on by default). While the debugger is paused, selecting an expression on one
line shows its value once the selection settles, with objects expandable like
the hover tooltip.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-29 09:12:40 +08:00
1 джерело 1c46a1cd04
коміт 7cfbf6c47b
8 files changed
+92 -3

No files matched your search

+21
Переглянути файл
@@ -1,4 +1,6 @@
import { describe, expect, it } from "vitest";
import { EditorSelection, EditorState } from "@codemirror/state";
import { selectionExpression } from "../editor/valueTooltip";
import { classifyValue, identifiersIn, inlineValue, sortVariables } from "../values";
import { inlineValuesFor } from "../editor/execution";
import { frameLabel, groupFrames, isLibraryFrame } from "../frames";
@@ -109,3 +111,22 @@ describe("sortVariables", () => {
expect(names(sortVariables(items))).toEqual(["[0]", "[1]", "[10]", "[2]"]);
});
});
describe("selectionExpression", () => {
const at = (doc: string, from: number, to: number) =>
selectionExpression(EditorState.create({ doc, selection: EditorSelection.single(from, to) }));
it("takes a one-line selection", () => {
expect(at("total += item.price", 9, 19)).toEqual({ from: 9, text: "item.price" });
});
it("ignores empty, blank, multi-line and multiple selections", () => {
expect(at("a + b", 2, 2)).toBeNull();
expect(at("a b", 1, 4)).toBeNull();
expect(at("a\nb", 0, 3)).toBeNull();
const multi = EditorState.create({
doc: "a + b",
selection: EditorSelection.create([EditorSelection.range(0, 1), EditorSelection.range(4, 5)]),
extensions: EditorState.allowMultipleSelections.of(true),
});
expect(selectionExpression(multi)).toBeNull();
});
});