дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-30 06:12:33 +02:00
feat(vcs): focus Git Log text filter with Ctrl+L (#6861)
Adds Focus Text Filter (Vcs.Log.FocusTextFilter, Ctrl+L) to Git Log and File History: from the commit list it focuses the message filter, from inside the filters toolbar it returns to the commit list. The action is ordered ahead of the Agents input (also Ctrl+L in the Windows keymap), which otherwise took the key whenever an agent task was on screen, and it leaves popups their own Ctrl+L. Eclipse keymaps share Go to Line's Ctrl+L with it; the title has a zh entry. Co-authored-by: muutot <[email protected]>
Цей коміт міститься в:
1 джерело
16c2613cc0
коміт
37e2e250e9
12 files changed
+145
-4
No files matched your search
@@ -74,6 +74,7 @@ async function openLogOnSd(page: Page) {
|
||||
operation: null,
|
||||
});
|
||||
h.vcs_status = () => [];
|
||||
h.fs_entry_kind = ({ path }) => (/\.(ts|md)$/.test(String(path)) ? "file" : "dir");
|
||||
h.vcs_branches = () => branches;
|
||||
h.vcs_stashes = () => [];
|
||||
h.vcs_tags = () => [];
|
||||
@@ -99,6 +100,9 @@ async function openLogOnSd(page: Page) {
|
||||
const storeModule = "/src/features/vcs/store.ts";
|
||||
const { useVcs, refreshNow, loadBranches } = await import(/* @vite-ignore */ storeModule);
|
||||
useVcs.setState({ available: true, root, repo: root, roots: [root], branchesLoaded: false, stashesLoaded: false });
|
||||
const contextModule = "/src/platform/context.ts";
|
||||
const { setContext } = await import(/* @vite-ignore */ contextModule);
|
||||
setContext("vcsAvailable", true);
|
||||
await refreshNow();
|
||||
await loadBranches();
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
@@ -108,6 +112,33 @@ async function openLogOnSd(page: Page) {
|
||||
await expect(page.getByRole("listbox", { name: "Commits" }).getByRole("option").first()).toBeVisible();
|
||||
}
|
||||
|
||||
test("Ctrl+L toggles focus between Git Log filters and commits, including File History", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await openLogOnSd(page);
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters", exact: true });
|
||||
const filter = toolbar.getByRole("textbox", { name: "Filter by message" });
|
||||
const commits = page.getByRole("listbox", { name: "Commits" });
|
||||
|
||||
await commits.focus();
|
||||
await page.keyboard.press("Control+L");
|
||||
await expect(filter).toBeFocused();
|
||||
await page.keyboard.press("Control+L");
|
||||
await expect(commits).toBeFocused();
|
||||
|
||||
await page.getByRole("treeitem", { name: "README.md", exact: true }).click({ button: "right" });
|
||||
await page.getByRole("menuitem", { name: "Git", exact: true }).hover();
|
||||
await page.getByRole("menuitem", { name: "Show History", exact: true }).click();
|
||||
const historyTab = page.getByRole("tablist", { name: "Git" }).getByRole("tab", { name: /History: README.md/ });
|
||||
await expect(historyTab).toHaveAttribute("aria-selected", "true");
|
||||
await expect(filter).toBeVisible();
|
||||
await commits.focus();
|
||||
await page.keyboard.press("Control+L");
|
||||
await expect(filter).toBeFocused();
|
||||
await page.keyboard.press("Control+L");
|
||||
await expect(commits).toBeFocused();
|
||||
});
|
||||
|
||||
test("the log branch filter follows a branch rename from the log's own toolbar", async ({ workbench: page }) => {
|
||||
await openLogOnSd(page);
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters", exact: true });
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { executeAction, getAction, isActionKeyEnabled } from "@/platform/actions";
|
||||
import { getContext, setContext } from "@/platform/context";
|
||||
import { IDEA_ACTIONS } from "@/platform/ideaActions";
|
||||
import { intellijMacos } from "@/platform/keymaps/intellij-macos";
|
||||
import { intellijWindows } from "@/platform/keymaps/intellij-windows";
|
||||
import { registerHistoryActions } from "../historyActions";
|
||||
|
||||
let unregister: (() => void) | undefined;
|
||||
const originalContext = getContext();
|
||||
|
||||
beforeEach(() => {
|
||||
setContext("vcsAvailable", true);
|
||||
setContext("activeToolWindow", "git");
|
||||
document.body.innerHTML = `
|
||||
<div data-vcs-log-filters><input aria-label="Filter by message" /></div>
|
||||
<div data-vcs-log-filters data-active>
|
||||
<button type="button">Branch</button>
|
||||
<input aria-label="Filter by message" />
|
||||
</div>
|
||||
<div data-vcs-log-commits data-active tabindex="0"></div>
|
||||
`;
|
||||
unregister = registerHistoryActions();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
unregister?.();
|
||||
unregister = undefined;
|
||||
setContext("vcsAvailable", originalContext.vcsAvailable);
|
||||
setContext("activeToolWindow", originalContext.activeToolWindow);
|
||||
document.body.replaceChildren();
|
||||
});
|
||||
|
||||
describe("Focus Text Filter", () => {
|
||||
it("maps IDEA's action and binds Ctrl+L only inside Git Log or File History", () => {
|
||||
const action = getAction("vcs.log.focusTextFilter")!;
|
||||
expect(action).toMatchObject({ title: "Focus Text Filter", category: "Git Log", keyWhen: expect.any(String) });
|
||||
expect(IDEA_ACTIONS["Vcs.Log.FocusTextFilter"]).toBe("vcs.log.focusTextFilter");
|
||||
expect(intellijWindows[action.id]).toEqual(["Ctrl+L"]);
|
||||
expect(intellijMacos[action.id]).toEqual(["Ctrl+L"]);
|
||||
expect(isActionKeyEnabled(action, { vcsAvailable: true, activeToolWindow: "git" })).toBe(true);
|
||||
expect(isActionKeyEnabled(action, { vcsAvailable: true, activeToolWindow: "editor", vcsLogFocus: true })).toBe(
|
||||
true,
|
||||
);
|
||||
expect(isActionKeyEnabled(action, { vcsAvailable: true, activeToolWindow: "editor", editorTextFocus: true })).toBe(
|
||||
false,
|
||||
);
|
||||
// A popup over the log (Find, a filter menu) keeps its own Ctrl+L.
|
||||
expect(isActionKeyEnabled(action, { vcsAvailable: true, activeToolWindow: "git", popupOpen: true })).toBe(false);
|
||||
});
|
||||
|
||||
it("focuses the active log's message filter from outside its toolbar", async () => {
|
||||
const commits = document.querySelector<HTMLElement>("[data-vcs-log-commits][data-active]")!;
|
||||
commits.focus();
|
||||
await executeAction("vcs.log.focusTextFilter");
|
||||
expect(document.activeElement).toBe(
|
||||
document.querySelector("[data-vcs-log-filters][data-active] [aria-label='Filter by message']"),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns to the active commit list when focus is inside the filters toolbar", async () => {
|
||||
const button = document.querySelector<HTMLButtonElement>("[data-vcs-log-filters][data-active] button")!;
|
||||
button.focus();
|
||||
await executeAction("vcs.log.focusTextFilter");
|
||||
expect(document.activeElement).toBe(document.querySelector("[data-vcs-log-commits][data-active]"));
|
||||
});
|
||||
|
||||
it("does nothing when no log view is active", async () => {
|
||||
document.body.replaceChildren();
|
||||
await executeAction("vcs.log.focusTextFilter");
|
||||
expect(document.activeElement).toBe(document.body);
|
||||
});
|
||||
});
|
||||
@@ -91,6 +91,15 @@ const IN_COMMIT = "vcsAvailable && activeToolWindow == commit";
|
||||
/** Shortcuts that act on the selected commit: only while the commit list has focus. */
|
||||
const IN_COMMITS = "vcsLogCommitsFocus";
|
||||
|
||||
function focusLogTextFilter() {
|
||||
const filters = document.querySelector<HTMLElement>("[data-vcs-log-filters][data-active]");
|
||||
const commits = document.querySelector<HTMLElement>("[data-vcs-log-commits][data-active]");
|
||||
const target = filters?.contains(document.activeElement)
|
||||
? commits
|
||||
: filters?.querySelector<HTMLElement>("[aria-label='Filter by message']");
|
||||
target?.focus({ preventScroll: true });
|
||||
}
|
||||
|
||||
/** The commit an action refers to: its argument (commit or id), else the Git Log selection. */
|
||||
export function commitArg(arg: unknown): Commit | null {
|
||||
const { commits, selected } = useGitLog.getState();
|
||||
@@ -396,6 +405,15 @@ export function registerHistoryActions(): () => void {
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "vcs.log.focusTextFilter",
|
||||
title: "Focus Text Filter",
|
||||
category: "Git Log",
|
||||
when: "vcsAvailable || projectOpen || vcsLogFocus",
|
||||
keyWhen: `${IN_GIT_LOG} && !popupOpen`,
|
||||
run: focusLogTextFilter,
|
||||
},
|
||||
|
||||
// --- Git Log commit context menu ---
|
||||
{
|
||||
id: "vcs.log.copyRevision",
|
||||
|
||||
@@ -554,6 +554,8 @@ export function CommitList({ fileHistory = false }: { fileHistory?: boolean }) {
|
||||
role="listbox"
|
||||
aria-label={tx("Commits")}
|
||||
aria-multiselectable
|
||||
data-vcs-log-commits
|
||||
data-active={active ? "" : undefined}
|
||||
aria-activedescendant={selectedIndex >= 0 ? `commit-${scope ?? "log"}-${selectedIndex}` : undefined}
|
||||
tabIndex={0}
|
||||
onFocusCapture={() => {
|
||||
|
||||
@@ -370,7 +370,13 @@ export function FilterBar({ fileHistory = false }: { fileHistory?: boolean }) {
|
||||
];
|
||||
|
||||
return (
|
||||
<div className={styles.filters} role="toolbar" aria-label={tx("Log filters")}>
|
||||
<div
|
||||
className={styles.filters}
|
||||
role="toolbar"
|
||||
aria-label={tx("Log filters")}
|
||||
data-vcs-log-filters
|
||||
data-active={active ? "" : undefined}
|
||||
>
|
||||
<div className={styles.filterControls}>
|
||||
{!fileHistory && !comparison && !showBranches && (
|
||||
<IconButton icon="chevron-right" title="Show Branches" size="small" action="vcs.log.showBranches" />
|
||||
|
||||
@@ -185,4 +185,5 @@ export const IDEA_ACTIONS: Readonly<Record<string, string>> = {
|
||||
ShowUmlDiagram: "db.showDiagram",
|
||||
ShowUmlDiagramPopup: "db.showDiagramPopup",
|
||||
"Vcs.CopyCommitSubjectAction": "vcs.log.copyCommitSubject",
|
||||
"Vcs.Log.FocusTextFilter": "vcs.log.focusTextFilter",
|
||||
};
|
||||
@@ -32,7 +32,7 @@ const owners = (km: Record<string, string[]>, key: string) =>
|
||||
// parent collisions are not introduced by this preset; new pairs must be reviewed here.
|
||||
const shared = [
|
||||
["navigate.gotoClass", "terminal.new"],
|
||||
["navigate.gotoLine", "agents.focusInput"],
|
||||
["navigate.gotoLine", "agents.focusInput", "vcs.log.focusTextFilter"],
|
||||
["navigate.recentLocations", "project.open", "debug.jumpToSource", "diff.jumpToSource", "find.popup.openResult"],
|
||||
[
|
||||
"navigate.declaration",
|
||||
|
||||
@@ -116,6 +116,7 @@ describe("IDEA keymap parity", () => {
|
||||
["find.recentUsages", [], []],
|
||||
// Vcs.Log.GoToRef: Find in the Git Log table.
|
||||
["vcs.log.goToRef", ["Meta+F"], ["Ctrl+F"]],
|
||||
["vcs.log.focusTextFilter", ["Ctrl+L"], ["Ctrl+L"]],
|
||||
// Back / Forward also carry the mouse side buttons (`<mouse-shortcut keystroke="button4"/>`).
|
||||
["editor.codeBlockStartWithSelection", ["Meta+Alt+Shift+["], ["Ctrl+Shift+["]],
|
||||
["editor.codeBlockEndWithSelection", ["Meta+Alt+Shift+]"], ["Ctrl+Shift+]"]],
|
||||
@@ -182,6 +183,9 @@ describe("IDEA keymap parity", () => {
|
||||
order(km, "navigate.nextOccurrence", "navigate.nextHighlightedUsage");
|
||||
order(km, "code.moveElementLeft", "toolwindow.resizeLeft");
|
||||
order(km, "find.inFile", "vcs.log.goToRef");
|
||||
order(km, "find.next", "vcs.log.focusTextFilter");
|
||||
order(km, "vcs.log.focusTextFilter", "agents.focusInput");
|
||||
order(km, "editor.scrollToCenter", "vcs.log.focusTextFilter");
|
||||
// Inline (text editor only) wins over New Branch.
|
||||
order(km, "vcs.newBranch", "refactor.inline");
|
||||
order(km, "vcs.addToVcs", "diff.applyRightSide");
|
||||
|
||||
@@ -481,6 +481,8 @@ export const intellijMacos: Record<string, string[]> = {
|
||||
"db.editCell": [],
|
||||
"db.showToolWindow": [],
|
||||
"agents.newTask": ["Meta+Shift+I"],
|
||||
// Git Log / File History, outside popups.
|
||||
"vcs.log.focusTextFilter": ["Ctrl+L"],
|
||||
"agents.focusInput": ["Meta+L"],
|
||||
"agents.cycleEffort": ["Alt+T"],
|
||||
"agents.showToolWindow": [],
|
||||
|
||||
@@ -479,6 +479,8 @@ export const intellijWindows: Record<string, string[]> = {
|
||||
"db.editCell": [],
|
||||
"db.showToolWindow": [],
|
||||
"agents.newTask": ["Ctrl+Alt+Shift+I"],
|
||||
// Git Log / File History (outside popups): before the Agents input, which yields to a panel claiming Ctrl+L.
|
||||
"vcs.log.focusTextFilter": ["Ctrl+L"],
|
||||
"agents.focusInput": ["Ctrl+L"],
|
||||
"agents.cycleEffort": ["Alt+T"],
|
||||
"agents.showToolWindow": [],
|
||||
|
||||
@@ -4780,5 +4780,6 @@
|
||||
"Cross-session learning for this task": "Cross-session learning for this task",
|
||||
"Session auto-memory mode": "Session auto-memory mode",
|
||||
"No memory files found.": "No memory files found.",
|
||||
"No matching memories.": "No matching memories."
|
||||
"No matching memories.": "No matching memories.",
|
||||
"Focus Text Filter": "Focus Text Filter"
|
||||
}
|
||||
@@ -11424,5 +11424,6 @@
|
||||
"Cross-session learning for this task": "此任务的跨会话学习策略",
|
||||
"Session auto-memory mode": "会话自动记忆模式",
|
||||
"No memory files found.": "未找到记忆文件。",
|
||||
"No matching memories.": "没有匹配的记忆。"
|
||||
"No matching memories.": "没有匹配的记忆。",
|
||||
"Focus Text Filter": "聚焦文本过滤器"
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача