mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 17:02:17 +00:00
feat(debugger): Browse the debug console history and open diff settings from the keyboard (#162)
- Debug console: typed expressions are kept per project, and Browse Console History (⌥⌘E / Ctrl+Alt+E) lists them, most recent first, to put one back into the input. - Diff viewer: Diff Settings (⇧⌘D / Ctrl+Shift+D) opens the viewer options (side-by-side / unified, whitespace, highlighting, collapsing, scroll sync) as a popup menu.
This commit is contained in:
1 parent
a28600c55a
commit
aeb190ffda
10 files changed
+142
-10
No files matched your search
@@ -21,7 +21,7 @@ import { setContext } from "@/platform/context";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { bindingsFor, normalizeBinding, shortcutLabel, strokeOf } from "@/platform/keymap";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { IconButton, Select, Spinner, T } from "@/ui";
|
||||
import { IconButton, Select, Spinner, T, showContextMenu } from "@/ui";
|
||||
import { editorService, type EditorInput } from "@/workbench/contributions";
|
||||
import { languageFor, viewerBase } from "./cm";
|
||||
import { applyChunk, arrowControls, chunkAt, hoverRevert } from "./diffControls";
|
||||
@@ -602,9 +602,70 @@ export function DiffEditor({ input }: { input: EditorInput }) {
|
||||
const neighbour = chainNeighbour(data, dir);
|
||||
if (neighbour) void openDiff(neighbour, { preview: true });
|
||||
};
|
||||
const nav = useRef<DiffNavigator>({ next: () => step(1), prev: () => step(-1), jumpToSource, applyChange, file });
|
||||
const toolbarRef = useRef<HTMLDivElement | null>(null);
|
||||
const showSettings = () => {
|
||||
const r = toolbarRef.current?.getBoundingClientRect();
|
||||
showContextMenu({ x: r ? r.left + 8 : 120, y: r ? r.bottom : 120 }, [
|
||||
{ kind: "header", label: "Viewer" },
|
||||
{
|
||||
id: "split",
|
||||
label: "Side-by-side Viewer",
|
||||
checked: opts.mode === "split",
|
||||
run: () => setOpts({ mode: "split" }),
|
||||
},
|
||||
{
|
||||
id: "unified",
|
||||
label: "Unified Viewer",
|
||||
checked: opts.mode === "unified",
|
||||
run: () => setOpts({ mode: "unified" }),
|
||||
},
|
||||
{ kind: "separator" },
|
||||
{
|
||||
id: "ignore",
|
||||
label: "Ignore Whitespace",
|
||||
submenu: IGNORE_OPTIONS.map((o) => ({
|
||||
id: o.value,
|
||||
label: o.label,
|
||||
checked: opts.ignore === o.value,
|
||||
run: () => setOpts({ ignore: o.value }),
|
||||
})),
|
||||
},
|
||||
{
|
||||
id: "highlight",
|
||||
label: "Highlighting",
|
||||
submenu: HIGHLIGHT_OPTIONS.map((o) => ({
|
||||
id: o.value,
|
||||
label: o.label,
|
||||
checked: opts.highlight === o.value,
|
||||
run: () => setOpts({ highlight: o.value }),
|
||||
})),
|
||||
},
|
||||
{ kind: "separator" },
|
||||
{
|
||||
id: "collapse",
|
||||
label: "Collapse Unchanged Fragments",
|
||||
checked: opts.collapse,
|
||||
run: () => setOpts({ collapse: !opts.collapse }),
|
||||
},
|
||||
{
|
||||
id: "sync",
|
||||
label: "Synchronize Scrolling",
|
||||
checked: opts.syncScroll,
|
||||
disabled: opts.mode !== "split",
|
||||
run: () => setOpts({ syncScroll: !opts.syncScroll }),
|
||||
},
|
||||
]);
|
||||
};
|
||||
const nav = useRef<DiffNavigator>({
|
||||
next: () => step(1),
|
||||
prev: () => step(-1),
|
||||
jumpToSource,
|
||||
applyChange,
|
||||
file,
|
||||
showSettings,
|
||||
});
|
||||
useEffect(() => {
|
||||
nav.current = { next: () => step(1), prev: () => step(-1), jumpToSource, applyChange, file };
|
||||
nav.current = { next: () => step(1), prev: () => step(-1), jumpToSource, applyChange, file, showSettings };
|
||||
});
|
||||
|
||||
useEffect(
|
||||
@@ -638,7 +699,7 @@ export function DiffEditor({ input }: { input: EditorInput }) {
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className={styles.toolbar} role="toolbar" aria-label={tx("Diff")}>
|
||||
<div ref={toolbarRef} className={styles.toolbar} role="toolbar" aria-label={tx("Diff")}>
|
||||
<IconButton
|
||||
icon="arrow-up"
|
||||
title="Previous Difference"
|
||||
|
||||
@@ -125,6 +125,15 @@ export function registerCompareActions(): () => void {
|
||||
when: "diffEditorFocus",
|
||||
run: () => focusedDiffNavigator()?.prev(),
|
||||
},
|
||||
{
|
||||
id: "diff.showSettings",
|
||||
title: "Diff Settings",
|
||||
category: "Diff",
|
||||
icon: "settings",
|
||||
keywords: ["ignore whitespace", "highlighting", "side-by-side", "unified"],
|
||||
when: "diffEditorFocus",
|
||||
run: () => focusedDiffNavigator()?.showSettings(),
|
||||
},
|
||||
{
|
||||
id: "diff.nextFile",
|
||||
title: "Compare Next File",
|
||||
|
||||
@@ -8,6 +8,8 @@ export interface DiffNavigator {
|
||||
applyChange(source: "a" | "b"): boolean;
|
||||
/** Open the next / previous file of the diff chain (changes of a commit or change list). */
|
||||
file(dir: 1 | -1): void;
|
||||
/** The viewer's settings as a popup menu (⇧⌘D). */
|
||||
showSettings(): void;
|
||||
}
|
||||
|
||||
let focused: DiffNavigator | null = null;
|
||||
|
||||
Reference in new issue
Block a user