дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 03:05:40 +02:00
feat(debugger): add paused editor evaluation entry points (#676)
While a debug session is paused, Alt/Option+click on a variable or expression runs Quick Evaluate at the clicked position (the selection when the click falls inside it) and shows the value next to it; outside a paused session Alt+click keeps its editor behaviour. The editor context menu offers Evaluate Expression… seeded with the selection or the expression at the caret while paused. Mouse shortcuts now pass the clicked editor and position to the action, and the binding is only consumed when its action is enabled. Fixes #664
Цей коміт міститься в:
1 джерело
f6d7facd82
коміт
87bf89d688
9 files changed
+255
-20
No files matched your search
@@ -407,15 +407,20 @@ function runIfEnabled(id: string): boolean {
|
||||
}
|
||||
|
||||
/** Run a configured mouse binding; editors prepare the clicked caret and focus first. */
|
||||
export function dispatchMouseShortcut(e: MouseEvent, prepare?: () => boolean): boolean {
|
||||
export function dispatchMouseShortcut(e: MouseEvent, prepare?: (id: string) => boolean, arg?: unknown): boolean {
|
||||
if (suspended > 0) return false;
|
||||
const stroke = mouseStrokeOf(e);
|
||||
if (!stroke) return false;
|
||||
const ids = effectiveBindings()
|
||||
.filter(([b]) => b === stroke)
|
||||
.map(([, id]) => id);
|
||||
if (!ids.length || (prepare && !prepare())) return false;
|
||||
for (const id of ids.reverse()) if (runIfEnabled(id)) return true;
|
||||
for (const id of ids.reverse()) {
|
||||
const action = getAction(id);
|
||||
if (!action || !isActionKeyEnabled(action)) continue;
|
||||
if (prepare && !prepare(id)) return false;
|
||||
void executeAction(id, arg);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
formatBinding,
|
||||
dispatchMouseShortcut,
|
||||
installKeyboardDispatcher,
|
||||
isMouseBinding,
|
||||
isValidBinding,
|
||||
@@ -13,6 +14,7 @@ import {
|
||||
useKeymap,
|
||||
} from "./keymap";
|
||||
import { registerAction } from "./actions";
|
||||
import { setContext } from "./context";
|
||||
|
||||
const noMods = { metaKey: false, ctrlKey: false, altKey: false, shiftKey: false };
|
||||
|
||||
@@ -84,6 +86,23 @@ describe("mouse shortcuts", () => {
|
||||
return events;
|
||||
};
|
||||
|
||||
it("does not prepare the editor for a disabled mouse action", () => {
|
||||
const run = vi.fn();
|
||||
const prepare = vi.fn(() => true);
|
||||
const remove = registerAction({ id: "test.pausedMouse", title: "Evaluate", when: "debugSessionPaused", run });
|
||||
useKeymap.setState({ overrides: { "test.pausedMouse": ["Alt+Button1"] } });
|
||||
setContext("debugSessionPaused", false);
|
||||
const e = new MouseEvent("mousedown", { button: 0, altKey: true, cancelable: true });
|
||||
try {
|
||||
expect(dispatchMouseShortcut(e, prepare)).toBe(false);
|
||||
expect(prepare).not.toHaveBeenCalled();
|
||||
expect(run).not.toHaveBeenCalled();
|
||||
expect(e.defaultPrevented).toBe(false);
|
||||
} finally {
|
||||
remove();
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["the editor", () => editor],
|
||||
["another component", () => document.getElementById("tree")!],
|
||||
|
||||
@@ -69,7 +69,7 @@ describe("IDEA keymap parity", () => {
|
||||
["navigate.nextHighlightedUsage", ["Ctrl+Alt+Down"], ["Ctrl+Alt+Down"]],
|
||||
["analyze.inspectFile", ["Alt+Shift+I"], ["Alt+Shift+I"]],
|
||||
["project.copyElement", ["F5"], ["F5"]],
|
||||
["debug.quickEvaluate", ["Meta+Alt+F8"], ["Ctrl+Alt+F8"]],
|
||||
["debug.quickEvaluate", ["Meta+Alt+F8", "Alt+Button1"], ["Ctrl+Alt+F8", "Alt+Button1"]],
|
||||
["run.chooseDebugConfig", ["Ctrl+Alt+D"], ["Alt+Shift+F9"]],
|
||||
["editor.nextSplitter", ["Alt+Tab"], ["Alt+Tab"]],
|
||||
["toolwindow.resizeLeft", ["Ctrl+Alt+Left"], ["Ctrl+Alt+Shift+Left"]],
|
||||
|
||||
@@ -284,7 +284,7 @@ export const intellijMacos: Record<string, string[]> = {
|
||||
"debug.setValue": ["F2"],
|
||||
"debug.jumpToSource": ["F4", "Meta+Down"],
|
||||
"debug.evaluate": ["Alt+F8"],
|
||||
"debug.quickEvaluate": ["Meta+Alt+F8"],
|
||||
"debug.quickEvaluate": ["Meta+Alt+F8", "Alt+Button1"],
|
||||
"debug.browseConsoleHistory": ["Meta+Alt+E"],
|
||||
|
||||
// VCS
|
||||
|
||||
@@ -278,7 +278,7 @@ export const intellijWindows: Record<string, string[]> = {
|
||||
"debug.setValue": ["F2"],
|
||||
"debug.jumpToSource": ["F4"],
|
||||
"debug.evaluate": ["Alt+F8"],
|
||||
"debug.quickEvaluate": ["Ctrl+Alt+F8"],
|
||||
"debug.quickEvaluate": ["Ctrl+Alt+F8", "Alt+Button1"],
|
||||
"debug.browseConsoleHistory": ["Ctrl+Alt+E"],
|
||||
|
||||
// VCS
|
||||
|
||||
Reference in new issue
Заблокувати користувача