дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 01:57:13 +02:00
Порівняти коміти
2
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
c51383d2f9 | ||
|
|
23edb66193 |
No files matched your search
@@ -314,30 +314,6 @@ pub struct SmartKeysSettings {
|
||||
pub insert_doc_stub: bool,
|
||||
/// Backspace › Unindent: `autoindent` (proper indent position) | `nearest` indent position | `none`.
|
||||
pub backspace_unindent: String,
|
||||
/// The styles Cycle Identifier Case goes through.
|
||||
pub cycle_case: CycleCaseSettings,
|
||||
}
|
||||
|
||||
/// Editor › General › Smart Keys › Cycle Identifier Case: the styles the action goes through.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct CycleCaseSettings {
|
||||
/// `snake_case`
|
||||
pub snake: bool,
|
||||
/// `SCREAMING_SNAKE_CASE`
|
||||
pub screaming: bool,
|
||||
/// `kebab-case`
|
||||
pub kebab: bool,
|
||||
/// `camelCase`
|
||||
pub camel: bool,
|
||||
/// `PascalCase`
|
||||
pub pascal: bool,
|
||||
}
|
||||
|
||||
impl Default for CycleCaseSettings {
|
||||
fn default() -> Self {
|
||||
Self { snake: true, screaming: true, kebab: true, camel: true, pascal: true }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SmartKeysSettings {
|
||||
@@ -359,7 +335,6 @@ impl Default for SmartKeysSettings {
|
||||
smart_indent: true,
|
||||
insert_doc_stub: true,
|
||||
backspace_unindent: "autoindent".into(),
|
||||
cycle_case: CycleCaseSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ test("project switcher keeps names and metadata on separate lines and highlights
|
||||
|
||||
await page.getByRole("button", { name: "acme-api", exact: true }).click();
|
||||
const popup = page.getByRole("dialog", { name: "Projects" });
|
||||
await expect(popup.getByText("Recent Projects")).toBeVisible();
|
||||
await expect(popup.getByText("Release Tools")).toHaveCount(0);
|
||||
await expect(popup.getByText("Release Tools")).toBeVisible();
|
||||
const local = popup.getByRole("option", { name: new RegExp(NAME) });
|
||||
await expectBelow(local, NAME, PATH);
|
||||
await expectBelow(local, PATH, BRANCH);
|
||||
@@ -52,8 +51,10 @@ test("project switcher keeps names and metadata on separate lines and highlights
|
||||
|
||||
const remote = popup.getByRole("option", { name: /Payment Ledger/ });
|
||||
await expect(remote.locator("[data-remote-badge]")).toHaveCount(1);
|
||||
await expect(remote.locator('[data-remote-kind="ssh"]')).toBeVisible();
|
||||
await expect(local.locator("[data-remote-badge]")).toHaveCount(0);
|
||||
await expectBelow(remote, "Payment Ledger", `${HOST}:${REMOTE_PATH}`);
|
||||
await expectBelow(remote, "Payment Ledger", HOST);
|
||||
await expectBelow(remote, HOST, REMOTE_PATH);
|
||||
|
||||
await page.setViewportSize({ width: 960, height: 700 });
|
||||
await page.keyboard.type(HOST);
|
||||
@@ -65,7 +66,7 @@ test("project switcher keeps names and metadata on separate lines and highlights
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.type(`${HOST}:${REMOTE_PATH}`);
|
||||
await expect(remote.locator("mark")).toHaveText(`${HOST}:${REMOTE_PATH}`);
|
||||
await expect(remote.locator("mark")).toHaveText([HOST, REMOTE_PATH]);
|
||||
|
||||
await page.keyboard.press("Escape");
|
||||
await page.keyboard.type("acme-api");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("keeps the project switcher flat while grouping Welcome and Recent Projects without row overlap", async ({
|
||||
test("groups recent projects by Local and remote host across Welcome, Recent Projects, and Project Popup without row overlap", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 980, height: 740 });
|
||||
@@ -71,43 +71,15 @@ test("keeps the project switcher flat while grouping Welcome and Recent Projects
|
||||
}
|
||||
});
|
||||
|
||||
// 1. The project widget uses the same row layout for local and remote projects.
|
||||
// 1. Project Widget dropdown keeps Open Projects flat and groups Recent Projects by host.
|
||||
await page.getByRole("button", { name: "openidea_all" }).click();
|
||||
const projectPopup = page.getByRole("dialog", { name: "Projects" });
|
||||
await expect(projectPopup).toBeVisible();
|
||||
await expect(projectPopup).toContainText("Open Projects");
|
||||
await expect(projectPopup).toContainText("Recent Projects");
|
||||
await expect(projectPopup).toContainText("dev-mbp1.local");
|
||||
await expect(projectPopup.getByText("Local", { exact: true })).toHaveCount(0);
|
||||
await expect(projectPopup).toContainText("Local");
|
||||
await expect(projectPopup).toContainText("Ubuntu-24.04");
|
||||
// The two section headers and every project badge share the same left inset.
|
||||
const headers = [
|
||||
projectPopup.getByText("Open Projects", { exact: true }),
|
||||
projectPopup.getByText("Recent Projects", { exact: true }),
|
||||
];
|
||||
const headerMetrics = await Promise.all(
|
||||
headers.map((header) =>
|
||||
header.evaluate((el) => {
|
||||
const style = getComputedStyle(el);
|
||||
const rect = el.getBoundingClientRect();
|
||||
return { x: rect.x + parseFloat(style.paddingLeft), height: rect.height, fontSize: style.fontSize };
|
||||
}),
|
||||
),
|
||||
);
|
||||
expect(headerMetrics[1]).toEqual(headerMetrics[0]);
|
||||
const projectRows = projectPopup.getByRole("option").filter({ hasText: "/git/" });
|
||||
await expect(projectRows).toHaveCount(7);
|
||||
await expect(projectRows.locator("[data-remote-badge]")).toHaveCount(4);
|
||||
const rowMetrics = await projectRows.evaluateAll((rows) =>
|
||||
rows.map((el) => ({
|
||||
x: el.firstElementChild!.getBoundingClientRect().x,
|
||||
height: el.getBoundingClientRect().height,
|
||||
})),
|
||||
);
|
||||
for (const row of rowMetrics) expect(row.x).toBeCloseTo(headerMetrics[0]!.x, 0);
|
||||
// Both open projects have no branch metadata and must have identical heights.
|
||||
expect(rowMetrics[0]!.height).toBeCloseTo(rowMetrics[1]!.height, 0);
|
||||
await expect(projectPopup.getByRole("separator")).toHaveCount(2);
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(projectPopup).toBeHidden();
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ test("Git Log settings group display and column options with aligned checkboxes"
|
||||
const columns = dialog.getByRole("region", { name: "Visible columns" });
|
||||
const tagNames = view.getByRole("checkbox", { name: "Show tag names" });
|
||||
const hash = columns.getByRole("checkbox", { name: "Hash" });
|
||||
await expect(view.getByRole("checkbox")).toHaveCount(4);
|
||||
await expect(view.getByRole("checkbox")).toHaveCount(5);
|
||||
await expect(columns.getByRole("checkbox")).toHaveCount(4);
|
||||
|
||||
for (const width of [1000, 520]) {
|
||||
|
||||
@@ -5975,20 +5975,6 @@ export type CustomKeymap = {
|
||||
overrides?: { [key in string]: string[] },
|
||||
};
|
||||
|
||||
/** Editor › General › Smart Keys › Cycle Identifier Case: the styles the action goes through. */
|
||||
export type CycleCaseSettings = {
|
||||
/** `snake_case` */
|
||||
snake?: boolean,
|
||||
/** `SCREAMING_SNAKE_CASE` */
|
||||
screaming?: boolean,
|
||||
/** `kebab-case` */
|
||||
kebab?: boolean,
|
||||
/** `camelCase` */
|
||||
camel?: boolean,
|
||||
/** `PascalCase` */
|
||||
pascal?: boolean,
|
||||
};
|
||||
|
||||
/**
|
||||
* A field watchpoint (DAP data breakpoint) on a `dataId` from [`DebugManager::data_breakpoint_info`]
|
||||
* (java-debug ids, `Class#field`, stay valid across sessions).
|
||||
@@ -15087,8 +15073,6 @@ export type SmartKeysSettings = {
|
||||
insertDocStub?: boolean,
|
||||
/** Backspace › Unindent: `autoindent` (proper indent position) | `nearest` indent position | `none`. */
|
||||
backspaceUnindent?: string,
|
||||
/** The styles Cycle Identifier Case goes through. */
|
||||
cycleCase?: CycleCaseSettings,
|
||||
};
|
||||
|
||||
export type SourceFolder = {
|
||||
|
||||
@@ -139,7 +139,6 @@ import { togglePinSelectedContent } from "@/workbench/toolwindows/content";
|
||||
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
|
||||
import { toggleReadOnly } from "./fileAttributes";
|
||||
import { codeVisionShown, toggleCodeVision } from "./codeVision";
|
||||
import { breadcrumbsShown, toggleBreadcrumbs } from "./breadcrumbs";
|
||||
import { appearanceSwitches, localAppearanceSwitches, toggleAppearance, type AppearanceSwitch } from "./gutterMenu";
|
||||
import { openNavBarPopup } from "./view/NavBarPopup";
|
||||
import {
|
||||
@@ -780,11 +779,6 @@ export async function toggleSchemeSwitch(key: SchemeSwitch, on = !editorPrefs()[
|
||||
}
|
||||
}
|
||||
|
||||
function activeBreadcrumbsShown(): boolean {
|
||||
const slot = activeSlot();
|
||||
return !!slot && breadcrumbsShown(slot.tabId, editorPrefs().breadcrumbs, slot.model.info?.id);
|
||||
}
|
||||
|
||||
/** IDEA's StickyLinesDisableForLangAction: the active document's known base language, if enabled. */
|
||||
function activeStickyLinesLanguage(): string | null {
|
||||
// A notebook cell has no base document: never change the last text tab's language setting.
|
||||
@@ -970,20 +964,6 @@ export function registerEditorActions(): () => void {
|
||||
localAppearanceSwitch("editor.toggleLocalWhitespaces", "whitespaces"),
|
||||
localAppearanceSwitch("editor.toggleLocalGutterIcons", "gutterIcons"),
|
||||
localAppearanceSwitch("editor.toggleLocalIndentGuides", "indentGuides"),
|
||||
{
|
||||
id: "editor.toggleBreadcrumbs",
|
||||
title: "Show Breadcrumbs",
|
||||
description: "Toggle display of the Breadcrumbs bar in the current editor.",
|
||||
category: "View",
|
||||
keywords: ["breadcrumbs", "navigation bar", "hide breadcrumbs"],
|
||||
when: "textEditorActive",
|
||||
enabled: () => !focusedCellEditor() && !!activeSlot(),
|
||||
toggled: activeBreadcrumbsShown,
|
||||
run: () => {
|
||||
const slot = activeSlot();
|
||||
if (slot) toggleBreadcrumbs(slot.tabId, editorPrefs().breadcrumbs, slot.model.info?.id);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "editor.toggleCodeVision",
|
||||
title: "Code Vision",
|
||||
@@ -1348,7 +1328,7 @@ export function registerEditorActions(): () => void {
|
||||
edit("code.joinLines", "Join Lines", (v) => joinLines(v)),
|
||||
edit("code.toggleCase", "Toggle Case", (v) => toggleCase(v), { keywords: ["upper", "lower"] }),
|
||||
edit("code.transpose", "Transpose", (v) => transpose(v), { category: "Editor Actions" }),
|
||||
edit("code.cycleCase", "Cycle Identifier Case", (v) => cycleCase(v, editorPrefs().smartKeys.cycleCase), {
|
||||
edit("code.cycleCase", "Cycle Identifier Case", (v) => cycleCase(v), {
|
||||
keywords: ["camel", "snake", "kebab", "pascal", "screaming"],
|
||||
}),
|
||||
caret("code.addCaretsToLineEnds", "Add Carets to Ends of Selected Lines", (v) => addCaretsToLineEnds(v), {
|
||||
|
||||
@@ -37,7 +37,6 @@ const { EditorSlot } = await import("./model/slot");
|
||||
const { gutterIconsOn, localAppearanceField } = await import("./cm/prefs");
|
||||
const { DEFAULT_SETTINGS } = await import("@/features/settings/model/schema");
|
||||
const { resetDistractionFree } = await import("@/workbench/distractionFree");
|
||||
const { clearBreadcrumbOverrides, pruneBreadcrumbOverrides, useBreadcrumbOverrides } = await import("./breadcrumbs");
|
||||
|
||||
let dispose: () => void;
|
||||
beforeAll(() => {
|
||||
@@ -46,7 +45,6 @@ beforeAll(() => {
|
||||
afterAll(() => dispose());
|
||||
afterEach(() => {
|
||||
activeSlot = null;
|
||||
clearBreadcrumbOverrides();
|
||||
useProject.setState({ settings: null });
|
||||
useContextKeys.setState({}, true);
|
||||
resetDistractionFree();
|
||||
@@ -282,94 +280,6 @@ describe("active editor appearance toggles", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Show Breadcrumbs action", () => {
|
||||
const id = "editor.toggleBreadcrumbs";
|
||||
const activate = (tabId: string, language = "typescript") => {
|
||||
activeSlot = { disposed: false, tabId, model: { info: { id: language } } } as never;
|
||||
};
|
||||
const setBreadcrumbs = (show: boolean, disabledLanguages: string[] = []) => {
|
||||
useProject.setState({
|
||||
settings: { editor: { breadcrumbs: { show, placement: "bottom", disabledLanguages } } } as never,
|
||||
});
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
setBreadcrumbs(true);
|
||||
useContextKeys.setState({ textEditorActive: true });
|
||||
});
|
||||
|
||||
it("is a View action mapped from IDEA", () => {
|
||||
expect(getAction(id)).toMatchObject({
|
||||
title: "Show Breadcrumbs",
|
||||
description: "Toggle display of the Breadcrumbs bar in the current editor.",
|
||||
category: "View",
|
||||
when: "textEditorActive",
|
||||
});
|
||||
expect(resolveActionId("EditorToggleShowBreadcrumbs")).toBe(id);
|
||||
});
|
||||
|
||||
it("changes only the active editor and leaves global settings untouched", async () => {
|
||||
activate("t1");
|
||||
const settings = structuredClone(useProject.getState().settings);
|
||||
const action = getAction(id);
|
||||
expect(actionToggled(action)).toBe(true);
|
||||
expect(await executeAction(id)).toBe(true);
|
||||
expect(actionToggled(action)).toBe(false);
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({ t1: false });
|
||||
expect(useProject.getState().settings).toEqual(settings);
|
||||
expect(ipc.settingsSet).not.toHaveBeenCalled();
|
||||
|
||||
activate("t2");
|
||||
expect(actionToggled(action)).toBe(true);
|
||||
expect(await executeAction(id)).toBe(true);
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({ t1: false, t2: false });
|
||||
activate("t1");
|
||||
expect(await executeAction(id)).toBe(true);
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({ t1: true, t2: false });
|
||||
});
|
||||
|
||||
it("lets a forced value override the global setting and disabled language", async () => {
|
||||
setBreadcrumbs(false, ["typescript"]);
|
||||
activate("t1");
|
||||
const action = getAction(id);
|
||||
expect(actionToggled(action)).toBe(false);
|
||||
expect(await executeAction(id)).toBe(true);
|
||||
expect(actionToggled(action)).toBe(true);
|
||||
activate("t2");
|
||||
expect(actionToggled(action)).toBe(false);
|
||||
});
|
||||
|
||||
it("keeps the override while untouched editors follow global changes", async () => {
|
||||
setBreadcrumbs(false);
|
||||
activate("t1");
|
||||
expect(await executeAction(id)).toBe(true);
|
||||
setBreadcrumbs(true);
|
||||
expect(actionToggled(getAction(id))).toBe(true);
|
||||
activate("t2");
|
||||
expect(actionToggled(getAction(id))).toBe(true);
|
||||
setBreadcrumbs(false);
|
||||
expect(actionToggled(getAction(id))).toBe(false);
|
||||
activate("t1");
|
||||
expect(actionToggled(getAction(id))).toBe(true);
|
||||
});
|
||||
|
||||
it("does not run without an active text editor", async () => {
|
||||
expect(await executeAction(id)).toBe(false);
|
||||
activate("t1");
|
||||
useContextKeys.setState({ textEditorActive: false });
|
||||
expect(await executeAction(id)).toBe(false);
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({});
|
||||
});
|
||||
|
||||
it("drops overrides for closed editors and when the session stops", () => {
|
||||
useBreadcrumbOverrides.setState({ t1: false, t2: true }, true);
|
||||
pruneBreadcrumbOverrides(new Set(["t1"]));
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({ t1: false });
|
||||
clearBreadcrumbOverrides();
|
||||
expect(useBreadcrumbOverrides.getState()).toEqual({});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Disable Sticky Lines for Language", () => {
|
||||
const id = "editor.disableStickyLinesForLanguage";
|
||||
const key = "editor.codeEditing.stickyLinesDisabledLanguages";
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { create } from "zustand";
|
||||
import type { EditorExtras } from "@/platform/editorSettings";
|
||||
|
||||
export const useBreadcrumbOverrides = create<Record<string, boolean>>(() => ({}));
|
||||
|
||||
export function breadcrumbsShown(
|
||||
tabId: string,
|
||||
prefs: EditorExtras["breadcrumbs"],
|
||||
language: string | undefined,
|
||||
): boolean {
|
||||
const forced = useBreadcrumbOverrides.getState()[tabId];
|
||||
return forced ?? (prefs.show && (!language || !prefs.disabledLanguages.includes(language)));
|
||||
}
|
||||
|
||||
export function toggleBreadcrumbs(
|
||||
tabId: string,
|
||||
prefs: EditorExtras["breadcrumbs"],
|
||||
language: string | undefined,
|
||||
): void {
|
||||
const shown = !breadcrumbsShown(tabId, prefs, language);
|
||||
useBreadcrumbOverrides.setState((state) => ({ ...state, [tabId]: shown }));
|
||||
}
|
||||
|
||||
export function pruneBreadcrumbOverrides(live: ReadonlySet<string>): void {
|
||||
const state = useBreadcrumbOverrides.getState();
|
||||
const closed = Object.keys(state).filter((id) => !live.has(id));
|
||||
if (!closed.length) return;
|
||||
const next = { ...state };
|
||||
for (const id of closed) delete next[id];
|
||||
useBreadcrumbOverrides.setState(next, true);
|
||||
}
|
||||
|
||||
export function clearBreadcrumbOverrides(): void {
|
||||
useBreadcrumbOverrides.setState({}, true);
|
||||
}
|
||||
@@ -36,7 +36,7 @@ import {
|
||||
} from "@codemirror/commands";
|
||||
import { SearchCursor } from "@codemirror/search";
|
||||
import { humpLeft, humpRight, wordStartLeft } from "../model/camelHumps";
|
||||
import { cycleIdentifierCase, wordSpan, type IdentifierCase } from "../model/identifierCase";
|
||||
import { cycleIdentifierCase, wordSpan } from "../model/identifierCase";
|
||||
import { restartSticky } from "./stickySelection";
|
||||
|
||||
type Node = ReturnType<ReturnType<typeof syntaxTree>["resolveInner"]>;
|
||||
@@ -1087,10 +1087,7 @@ const NAME_CHAR = /[\p{L}\p{N}_$-]/u;
|
||||
* or of each selection, from the style it is written in: snake_case →
|
||||
* SCREAMING_SNAKE_CASE → kebab-case → camelCase → PascalCase.
|
||||
*/
|
||||
export const cycleCase = (
|
||||
view: EditorView,
|
||||
enabled: Readonly<Partial<Record<IdentifierCase, boolean>>> = {},
|
||||
): boolean => {
|
||||
export const cycleCase: Command = (view) => {
|
||||
const { state } = view;
|
||||
if (state.readOnly) return false;
|
||||
/** The `-`-joined name at or right before `pos`. */
|
||||
@@ -1110,7 +1107,7 @@ export const cycleCase = (
|
||||
const span = wordSpan(state.sliceDoc(name.from, name.to));
|
||||
if (!span) return { range: r };
|
||||
const from = name.from + span.from;
|
||||
const insert = cycleIdentifierCase(state.sliceDoc(from, name.from + span.to), enabled);
|
||||
const insert = cycleIdentifierCase(state.sliceDoc(from, name.from + span.to));
|
||||
if (insert === null) return { range: r };
|
||||
changed = true;
|
||||
const set = state.changes({ from, to: name.from + span.to, insert });
|
||||
|
||||
@@ -130,7 +130,6 @@ import { isVirtualUri, virtualDocument } from "@/platform/virtualDocs";
|
||||
import type { VirtualDocument } from "@/platform/ipc";
|
||||
import type { Scheduler } from "./sync/DocSync";
|
||||
import { selectedLineContext, selectedLines } from "./selectedLines";
|
||||
import { clearBreadcrumbOverrides, pruneBreadcrumbOverrides } from "./breadcrumbs";
|
||||
|
||||
export const fileKey = (path: string) => `file:${path}`;
|
||||
export const fileInput = (path: string): EditorInput => ({ kind: "file", key: fileKey(path), path });
|
||||
@@ -548,7 +547,6 @@ export class EditorController implements SlotHost {
|
||||
this.preparedDocuments.clear();
|
||||
for (const slot of this.slots.values()) slot.dispose();
|
||||
this.slots.clear();
|
||||
clearBreadcrumbOverrides();
|
||||
this.selectionRequests.clear();
|
||||
this.manager.stop();
|
||||
useTabs.setState(initialTabsState(), true);
|
||||
@@ -565,7 +563,6 @@ export class EditorController implements SlotHost {
|
||||
private onTabsChanged(prev: TabsState, next: TabsState) {
|
||||
const live = new Set<string>();
|
||||
for (const p of Object.values(next.panes)) for (const t of p.tabs) live.add(t.id);
|
||||
pruneBreadcrumbOverrides(live);
|
||||
for (const id of this.selectionRequests.keys()) if (!live.has(id)) this.selectionRequests.delete(id);
|
||||
|
||||
for (const [id, slot] of this.slots) {
|
||||
|
||||
@@ -39,21 +39,6 @@ describe("cycle identifier case", () => {
|
||||
expect(cycleIdentifierCase("MyVarName")).toBe("my_var_name");
|
||||
});
|
||||
|
||||
it("goes only through the styles turned on, starting from the one the name is written in", () => {
|
||||
const camelSnake = { screaming: false, kebab: false, pascal: false };
|
||||
expect(cycleIdentifierCase("myVarName", camelSnake)).toBe("my_var_name");
|
||||
expect(cycleIdentifierCase("my_var_name", camelSnake)).toBe("myVarName");
|
||||
// A name in a style that is turned off still moves on to the next one that is on.
|
||||
expect(cycleIdentifierCase("my-var-name", camelSnake)).toBe("myVarName");
|
||||
expect(cycleIdentifierCase("MyVarName", camelSnake)).toBe("my_var_name");
|
||||
// Only the name's own style on: nothing else to go to.
|
||||
expect(
|
||||
cycleIdentifierCase("myVarName", { snake: false, screaming: false, kebab: false, pascal: false }),
|
||||
).toBeNull();
|
||||
// One word in snake_case is written as in camelCase, so with Name and NAME off it stays.
|
||||
expect(cycleIdentifierCase("name", { pascal: false, screaming: false })).toBeNull();
|
||||
});
|
||||
|
||||
it("gives one word its three spellings: name → Name → NAME", () => {
|
||||
expect(cycleIdentifierCase("name")).toBe("Name");
|
||||
expect(cycleIdentifierCase("Name")).toBe("NAME");
|
||||
|
||||
@@ -81,20 +81,14 @@ export function toIdentifierCase(text: string, style: IdentifierCase): string {
|
||||
|
||||
/**
|
||||
* `text` in the next style of the cycle, skipping the styles that write it the
|
||||
* same way and those `enabled` turns off (Settings › Editor › General › Smart
|
||||
* Keys); null when none writes it differently.
|
||||
* same way; null when none writes it differently.
|
||||
*/
|
||||
export function cycleIdentifierCase(
|
||||
text: string,
|
||||
enabled: Readonly<Partial<Record<IdentifierCase, boolean>>> = {},
|
||||
): string | null {
|
||||
export function cycleIdentifierCase(text: string): string | null {
|
||||
const current = identifierCase(text);
|
||||
if (!current) return null;
|
||||
// One word has three spellings, not five: name → Name → NAME.
|
||||
const single = identifierWords(text).length === 1 && !SEPARATOR.test(text);
|
||||
const all: readonly IdentifierCase[] = single ? ["camel", "pascal", "screaming", "snake"] : identifierCases;
|
||||
// The style the name is written in stays the starting point even when it is turned off.
|
||||
const order = all.filter((style) => style === current || enabled[style] !== false);
|
||||
const order: readonly IdentifierCase[] = single ? ["camel", "pascal", "screaming", "snake"] : identifierCases;
|
||||
const start = Math.max(0, order.indexOf(current));
|
||||
for (let step = 1; step <= order.length; step++) {
|
||||
const next = toIdentifierCase(text, order[(start + step) % order.length]!);
|
||||
|
||||
@@ -31,7 +31,6 @@ import {
|
||||
untitledTitle,
|
||||
} from "@/platform/virtualDocs";
|
||||
import { editorController, isTextInput, useEditorStatus, useGotoLine, useTabs } from "../controller";
|
||||
import { useBreadcrumbOverrides } from "../breadcrumbs";
|
||||
import { languageInfo } from "../cm/languages";
|
||||
import { useDocMeta, useOutline, type DocMeta } from "../model/document";
|
||||
import { symbolChain } from "./outline";
|
||||
@@ -366,7 +365,6 @@ export function CodeBreadcrumbs({
|
||||
position: "top" | "bottom";
|
||||
}) {
|
||||
const { breadcrumbs: prefs, fallbackFont } = useEditorPrefs();
|
||||
const forced = useBreadcrumbOverrides((s) => s[tabId]);
|
||||
const editorSettings = useProject((s) => s.settings?.editor);
|
||||
const language = useDocMeta((s) => s[path]?.language);
|
||||
const outline = useOutline((s) => s[path]);
|
||||
@@ -377,8 +375,13 @@ export function CodeBreadcrumbs({
|
||||
const caret = editorController().slots.get(tabId)?.caret();
|
||||
chain = outline ? symbolChain(outline, caret?.line ?? 0, caret?.col ?? 0) : NO_SYMBOLS;
|
||||
}
|
||||
const shown = forced ?? (prefs.show && (!language || !prefs.disabledLanguages.includes(language)));
|
||||
if (!shown || prefs.placement !== position || !chain.length) return null;
|
||||
if (
|
||||
!prefs.show ||
|
||||
prefs.placement !== position ||
|
||||
(language && prefs.disabledLanguages.includes(language)) ||
|
||||
!chain.length
|
||||
)
|
||||
return null;
|
||||
const family = editorSettings?.fontFamily;
|
||||
const fontFamily =
|
||||
(family && family !== BUNDLED_MONO_FAMILY) || fallbackFont.trim()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Profiler } from "react";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import type { OutlineItem, Settings } from "@/platform/ipc";
|
||||
import type { EditorStatus } from "../controller";
|
||||
@@ -24,9 +24,6 @@ const { clearProjectViewLead, setProjectViewLead } = await import("@/workbench/c
|
||||
const { Breadcrumbs, CodeBreadcrumbs } = await import("./StatusItems");
|
||||
const { NavBarPopup, openNavBarPopup, useNavBarPopup } = await import("./NavBarPopup");
|
||||
const { useContextMenuStore } = await import("@/ui");
|
||||
const { clearBreadcrumbOverrides, useBreadcrumbOverrides } = await import("../breadcrumbs");
|
||||
|
||||
afterEach(() => clearBreadcrumbOverrides());
|
||||
|
||||
const PATH = "/p/Orders.ts";
|
||||
const span = (from: number, to: number) => ({ start: { line: from, col: 0 }, end: { line: to, col: 0 } });
|
||||
@@ -95,31 +92,6 @@ describe("caret-driven status widgets", () => {
|
||||
expect(commits).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("renders the active editor's forced breadcrumb visibility", () => {
|
||||
useProject.setState({
|
||||
settings: {
|
||||
appearance: { navigationBar: "top" },
|
||||
editor: { breadcrumbs: { show: false, placement: "bottom", disabledLanguages: ["typescript"] } },
|
||||
} as never,
|
||||
});
|
||||
useOutline.setState({ [PATH]: [item("Orders", 0, 40, [item("place", 2, 10)])] });
|
||||
act(() => useEditorStatus.setState({ status: caret(3, 4) }));
|
||||
render(
|
||||
<>
|
||||
<CodeBreadcrumbs path={PATH} tabId="t1" position="bottom" />
|
||||
<CodeBreadcrumbs path={PATH} tabId="t2" position="bottom" />
|
||||
</>,
|
||||
);
|
||||
expect(screen.queryByRole("navigation", { name: "Code breadcrumbs" })).toBeNull();
|
||||
|
||||
act(() => useBreadcrumbOverrides.setState({ t1: true }));
|
||||
expect(screen.getAllByRole("navigation", { name: "Code breadcrumbs" })).toHaveLength(1);
|
||||
expect(screen.getByRole("navigation", { name: "Code breadcrumbs" }).textContent).toContain("place");
|
||||
|
||||
act(() => useBreadcrumbOverrides.setState({ t1: false }));
|
||||
expect(screen.queryByRole("navigation", { name: "Code breadcrumbs" })).toBeNull();
|
||||
});
|
||||
|
||||
it("follows the caret into a Vue component's <script> declarations", () => {
|
||||
useOutline.setState({
|
||||
[PATH]: [item("template", 0, 4), { ...item("script", 5, 30), children: [item("size", 10, 20)] }],
|
||||
|
||||
@@ -21,13 +21,7 @@ vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
};
|
||||
});
|
||||
|
||||
vi.mock("@/platform/clipboard", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/platform/clipboard")>()),
|
||||
writeClipboardText: vi.fn(async () => {}),
|
||||
}));
|
||||
|
||||
import { getAction, registerAction, executeAction } from "@/platform/actions";
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { registerAction, executeAction } from "@/platform/actions";
|
||||
import { usePlatform } from "@/platform/platformInfo";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { useKeymap } from "@/platform/keymap";
|
||||
@@ -40,16 +34,13 @@ import { ProjectStructureDialog } from "../languages/ProjectStructurePage";
|
||||
import { SettingsWindow } from "../window/SettingsWindow";
|
||||
import dialogStyles from "../dialog/SettingsDialog.module.css";
|
||||
import { activate } from "..";
|
||||
import { copySettingsPath } from "../actions";
|
||||
import { MessagesHost } from "@/workbench/messages";
|
||||
import { resolveActionId } from "@/features/vim/rc";
|
||||
|
||||
let current: Settings;
|
||||
let dispose: () => void = () => {};
|
||||
const HTTP_PROXY_CONTEXT = { pageId: "general.httpProxy", scope: "global" } as const;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.mocked(writeClipboardText).mockClear();
|
||||
current = structuredClone(DEFAULT_SETTINGS) as Settings;
|
||||
settingsSet.mockReset().mockImplementation(async (_scope: string, key: string, json: string) => {
|
||||
current = setAt(current, key, JSON.parse(json));
|
||||
@@ -62,10 +53,7 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
act(() => {
|
||||
closeSettings();
|
||||
useSettingsDialog.setState({ projectStructureOpen: false });
|
||||
});
|
||||
act(() => useSettingsDialog.setState({ open: false, projectStructureOpen: false }));
|
||||
act(hideContextMenu);
|
||||
dispose();
|
||||
});
|
||||
@@ -84,32 +72,6 @@ async function openDialog(page?: string) {
|
||||
}
|
||||
|
||||
describe("Settings dialog", () => {
|
||||
it("copies the current Settings page path through the IDEA action", async () => {
|
||||
expect(getAction("settings.copyPath")).toMatchObject({
|
||||
title: "Copy Settings Path",
|
||||
description: "Copy the relative path to the selected configurable option",
|
||||
category: "Settings",
|
||||
when: "settingsOpen",
|
||||
});
|
||||
expect(resolveActionId("CopySettingsPath")).toBe("settings.copyPath");
|
||||
expect(await executeAction("settings.copyPath")).toBe(false);
|
||||
expect(writeClipboardText).not.toHaveBeenCalled();
|
||||
|
||||
await openDialog("editor.font");
|
||||
await act(async () => expect(await executeAction("settings.copyPath")).toBe(true));
|
||||
expect(writeClipboardText).toHaveBeenCalledWith("Settings | Editor | Font");
|
||||
expect(await copySettingsPath("missing.page")).toBe(false);
|
||||
expect(writeClipboardText).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("offers Copy Settings Path in the page tree context menu", async () => {
|
||||
const dialog = await openDialog("editor.font");
|
||||
render(<ContextMenuHost />);
|
||||
fireEvent.contextMenu(within(dialog).getByRole("treeitem", { name: "Font" }), { button: 2 });
|
||||
fireEvent.click(await screen.findByRole("menuitem", { name: "Copy Settings Path" }));
|
||||
await vi.waitFor(() => expect(writeClipboardText).toHaveBeenCalledWith("Settings | Editor | Font"));
|
||||
});
|
||||
|
||||
it("offers new window, current window, a new tab and ask, but not attach", async () => {
|
||||
current = setAt(current, "general.openProjectIn", "attach");
|
||||
const dialog = await openDialog("general");
|
||||
|
||||
@@ -1,24 +1,9 @@
|
||||
import type { Action } from "@/platform/actions";
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { useSettingsPages } from "@/workbench/contributions";
|
||||
import { breadcrumb, buildPageTree } from "./model/pages";
|
||||
import { useSettingsDialog } from "./model/staging";
|
||||
import { nativeToAsciiAction } from "./nativeToAscii";
|
||||
|
||||
/** Java's page first: JDK, Maven and the language server are what new projects most often need. */
|
||||
export const NEW_PROJECTS_PAGE = "languages.java";
|
||||
|
||||
export async function copySettingsPath(pageId?: string): Promise<boolean> {
|
||||
const state = useSettingsDialog.getState();
|
||||
if (!state.open) return false;
|
||||
const tree = buildPageTree(useSettingsPages.getState().pages.values());
|
||||
const names = breadcrumb(tree, pageId ?? state.pageId);
|
||||
if (!names.length) return false;
|
||||
await writeClipboardText([tx("Settings"), ...names.map((name) => tx(name))].join(" | "));
|
||||
return true;
|
||||
}
|
||||
|
||||
export function settingsActions(open: (page?: string, newProjects?: boolean) => void | Promise<void>): Action[] {
|
||||
return [
|
||||
nativeToAsciiAction(),
|
||||
@@ -30,18 +15,6 @@ export function settingsActions(open: (page?: string, newProjects?: boolean) =>
|
||||
keywords: ["preferences", "options", "configure"],
|
||||
run: ({ arg }) => open(typeof arg === "string" ? arg : undefined),
|
||||
},
|
||||
{
|
||||
id: "settings.copyPath",
|
||||
title: "Copy Settings Path",
|
||||
description: "Copy the relative path to the selected configurable option",
|
||||
category: "Settings",
|
||||
keywords: ["copy option path", "settings path", "breadcrumb"],
|
||||
when: "settingsOpen",
|
||||
enabled: () => useSettingsDialog.getState().open,
|
||||
run: async ({ arg }) => {
|
||||
await copySettingsPath(typeof arg === "string" ? arg : undefined);
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "file.newProjectsSettings",
|
||||
title: "Settings for New Projects…",
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
*/
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useProject } from "@/platform/project";
|
||||
import {
|
||||
SettingsFormContext,
|
||||
@@ -24,7 +23,6 @@ import {
|
||||
Icon,
|
||||
IconButton,
|
||||
SearchField,
|
||||
showContextMenu,
|
||||
Spinner,
|
||||
SplitGroup,
|
||||
SplitHandle,
|
||||
@@ -359,12 +357,6 @@ export function SettingsLayout() {
|
||||
indent={16}
|
||||
selected={current ? new Set([current.key]) : new Set()}
|
||||
onSelectionChange={(_sel, node) => node && selectPage(node.key)}
|
||||
onContextMenu={(node, _selected, event) => {
|
||||
if (!node) return;
|
||||
showContextMenu(event, [
|
||||
{ label: tx("Copy Settings Path"), run: () => void executeAction("settings.copyPath", node.key) },
|
||||
]);
|
||||
}}
|
||||
multiSelect={false}
|
||||
speedSearch={false}
|
||||
empty={
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*/
|
||||
import { create } from "zustand";
|
||||
import { overrideActions } from "@/platform/actions";
|
||||
import { setContext } from "@/platform/context";
|
||||
import { call, commands, isTauri, type Settings } from "@/platform/ipc";
|
||||
import { loadSettings, useProject } from "@/platform/project";
|
||||
import { lastSettingsPage, rememberSettingsPage } from "./lastPage";
|
||||
@@ -149,7 +148,6 @@ export function openSettings(pageId?: string, opts: { newProjects?: boolean; glo
|
||||
saving: false,
|
||||
error: null,
|
||||
});
|
||||
setContext("settingsOpen", true);
|
||||
if (!newProjects) rememberSettingsPage(target.pageId);
|
||||
if (!opts.globalBase) void loadGlobalBase();
|
||||
}
|
||||
@@ -176,7 +174,6 @@ export function openProjectStructure(section?: string, module: string | null = n
|
||||
saving: false,
|
||||
error: null,
|
||||
});
|
||||
setContext("settingsOpen", false);
|
||||
void loadGlobalBase();
|
||||
}
|
||||
|
||||
@@ -252,7 +249,6 @@ export function closeSettings() {
|
||||
saving: false,
|
||||
pagesLoading: false,
|
||||
});
|
||||
setContext("settingsOpen", false);
|
||||
}
|
||||
|
||||
let disposePageHistoryActions: (() => void) | null = null;
|
||||
|
||||
@@ -819,9 +819,6 @@ const SMART_KEYS = editorPage({
|
||||
"whitespace",
|
||||
"indent",
|
||||
"semicolon",
|
||||
"case",
|
||||
"snake case",
|
||||
"camel case",
|
||||
],
|
||||
sections: [
|
||||
{
|
||||
@@ -916,16 +913,6 @@ const SMART_KEYS = editorPage({
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Cycle Identifier Case",
|
||||
items: [
|
||||
{ t: "check", key: `${P}.smartKeys.cycleCase.snake`, label: "snake_case" },
|
||||
{ t: "check", key: `${P}.smartKeys.cycleCase.screaming`, label: "SCREAMING_SNAKE_CASE" },
|
||||
{ t: "check", key: `${P}.smartKeys.cycleCase.kebab`, label: "kebab-case" },
|
||||
{ t: "check", key: `${P}.smartKeys.cycleCase.camel`, label: "camelCase" },
|
||||
{ t: "check", key: `${P}.smartKeys.cycleCase.pascal`, label: "PascalCase" },
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, type ReactNode } from "react";
|
||||
import type { EditorInput } from "@/workbench/contributions";
|
||||
import { LogIdContext, LogOptionsContext } from "./logContext";
|
||||
import { applicationLogOptions, rootLogOptions } from "./logOptions";
|
||||
import { rootLogOptions } from "./logOptions";
|
||||
import { ensureEditorLog, focusLogView, parkedLogOptions, useRootGitLog } from "./logStore";
|
||||
import { LogView } from "./GitLog";
|
||||
import styles from "./GitLog.module.css";
|
||||
@@ -9,11 +9,7 @@ import styles from "./GitLog.module.css";
|
||||
export function LogScope({ id, children }: { id: string; children: ReactNode }) {
|
||||
const active = useRootGitLog((s) => s.shownLog);
|
||||
const options = rootLogOptions();
|
||||
const value = useMemo(() => {
|
||||
if (active === id) return options;
|
||||
const parked = parkedLogOptions(id);
|
||||
return parked ? { ...parked, ...applicationLogOptions(options) } : options;
|
||||
}, [active, id, options]);
|
||||
const value = useMemo(() => (active === id ? options : (parkedLogOptions(id) ?? options)), [active, id, options]);
|
||||
const focus = () => {
|
||||
if (useRootGitLog.getState().shownLog !== id) focusLogView(id);
|
||||
};
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/** Settings › Version Control › Log: how the Git Log shows references, dates and columns. */
|
||||
import { useId, type ReactNode } from "react";
|
||||
import { Checkbox, T } from "@/ui";
|
||||
import { setLogOptions, useLogOptions, type ApplicationLogOptions } from "./logOptions";
|
||||
import { setLogOptions, useLogOptions, type LogOptions } from "./logOptions";
|
||||
import styles from "./LogSettingsPage.module.css";
|
||||
|
||||
type Flag = {
|
||||
[K in keyof ApplicationLogOptions]: ApplicationLogOptions[K] extends boolean ? K : never;
|
||||
}[keyof ApplicationLogOptions];
|
||||
type Flag = { [K in keyof LogOptions]: LogOptions[K] extends boolean ? K : never }[keyof LogOptions];
|
||||
|
||||
const OPTIONS: { key: Flag; label: string }[] = [
|
||||
{ key: "compactRefs", label: "Show only the first reference" },
|
||||
{ key: "tagNames", label: "Show tag names" },
|
||||
{ key: "commitTimestamp", label: "Show commit time rather than author time" },
|
||||
{ key: "refsOnLeft", label: "Show references on the left" },
|
||||
{ key: "showLineStats", label: "Show lines added and deleted" },
|
||||
];
|
||||
|
||||
const COLUMNS: { key: Flag; label: string }[] = [
|
||||
|
||||
@@ -145,19 +145,10 @@ describe("log options", () => {
|
||||
expect(setLogOptions({ diffPreview: false })).toBe(false);
|
||||
});
|
||||
|
||||
it("reloads only for options that change the query and persists only application-level properties", () => {
|
||||
it("reloads only for options that change the query", () => {
|
||||
expect(setLogOptions({ compactRefs: false })).toBe(false);
|
||||
expect(setLogOptions({ noMerges: true, showHash: true })).toBe(true);
|
||||
const stored = JSON.parse(localStorage.getItem("openidea.vcs.logOptions")!);
|
||||
expect(stored).toMatchObject({ compactRefs: false, showHash: true });
|
||||
expect(stored).not.toHaveProperty("noMerges");
|
||||
});
|
||||
|
||||
it("applies application settings from another window without replacing the active tab's options", () => {
|
||||
setLogOptions({ noMerges: true });
|
||||
localStorage.setItem("openidea.vcs.logOptions", JSON.stringify({ compactRefs: false }));
|
||||
window.dispatchEvent(new StorageEvent("storage", { key: "openidea.vcs.logOptions" }));
|
||||
expect(useLogOptions.getState()).toMatchObject({ noMerges: true, compactRefs: false });
|
||||
expect(setLogOptions({ noMerges: true })).toBe(true);
|
||||
expect(JSON.parse(localStorage.getItem("openidea.vcs.logOptions")!).noMerges).toBe(true);
|
||||
});
|
||||
|
||||
it("sends the graph options and the date range to the backend", async () => {
|
||||
|
||||
@@ -530,5 +530,7 @@ describe("Settings › Version Control › Log", () => {
|
||||
expect(useLogOptions.getState().tagNames).toBe(!DEFAULT_LOG_OPTIONS.tagNames);
|
||||
fireEvent.click(screen.getByLabelText("Hash"));
|
||||
expect(useLogOptions.getState().showHash).toBe(!DEFAULT_LOG_OPTIONS.showHash);
|
||||
fireEvent.click(screen.getByLabelText("Show lines added and deleted"));
|
||||
expect(useLogOptions.getState().showLineStats).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -58,12 +58,8 @@ afterEach(async () => {
|
||||
|
||||
function Probe({ name }: { name: string }) {
|
||||
const text = useGitLog((s) => s.filters.text);
|
||||
const longEdges = useLogOptions((s) => s.longEdges);
|
||||
return (
|
||||
<button
|
||||
onClick={() => setLogFilters({ text: `${name} edited` })}
|
||||
>{`${name}: ${text} / long edges ${longEdges}`}</button>
|
||||
);
|
||||
const hash = useLogOptions((s) => s.showHash);
|
||||
return <button onClick={() => setLogFilters({ text: `${name} edited` })}>{`${name}: ${text} / hash ${hash}`}</button>;
|
||||
}
|
||||
|
||||
describe("independent log views", () => {
|
||||
@@ -71,7 +67,7 @@ describe("independent log views", () => {
|
||||
setLogFilters({ text: "main" });
|
||||
const other = openLogTab("log", "Other");
|
||||
setLogFilters({ text: "other" });
|
||||
updateLogOptions({ longEdges: true });
|
||||
updateLogOptions({ showHash: true });
|
||||
selectGitTab("log");
|
||||
render(
|
||||
<>
|
||||
@@ -83,16 +79,16 @@ describe("independent log views", () => {
|
||||
</LogScope>
|
||||
</>,
|
||||
);
|
||||
expect(screen.getByText("main: main / long edges false")).toBeInTheDocument();
|
||||
expect(screen.getByText("other: other / long edges true")).toBeInTheDocument();
|
||||
const button = screen.getByText("other: other / long edges true");
|
||||
expect(screen.getByText("main: main / hash false")).toBeInTheDocument();
|
||||
expect(screen.getByText("other: other / hash true")).toBeInTheDocument();
|
||||
const button = screen.getByText("other: other / hash true");
|
||||
await act(async () => {
|
||||
fireEvent.pointerDown(button);
|
||||
fireEvent.click(button);
|
||||
});
|
||||
expect(useGitLog.getState().shownLog).toBe(other);
|
||||
expect(screen.getByText("main: main / long edges false")).toBeInTheDocument();
|
||||
expect(screen.getByText("other: other edited / long edges true")).toBeInTheDocument();
|
||||
expect(screen.getByText("main: main / hash false")).toBeInTheDocument();
|
||||
expect(screen.getByText("other: other edited / hash true")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("restores each tab's filters and options after leaving and reopening the project", async () => {
|
||||
@@ -109,9 +105,8 @@ describe("independent log views", () => {
|
||||
selected: "/repo\0expanded",
|
||||
selection: ["/repo\0expanded"],
|
||||
});
|
||||
updateLogOptions({ longEdges: true, diffLocation: "bottom" });
|
||||
updateLogOptions({ showHash: true, diffLocation: "bottom" });
|
||||
selectGitTab("log");
|
||||
expect(useLogOptions.getState()).toMatchObject({ longEdges: false, diffLocation: "bottom" });
|
||||
await reloadLog();
|
||||
useVcs.setState({ root: "/another", repo: "/another", roots: ["/another"] });
|
||||
useVcs.setState({ root: "/repo", repo: "/repo", roots: ["/repo"] });
|
||||
@@ -119,7 +114,7 @@ describe("independent log views", () => {
|
||||
expect(useGitLog.getState().fragments.expanded.size).toBe(0);
|
||||
selectGitTab(other);
|
||||
expect(useGitLog.getState().filters).toMatchObject({ paths: ["/repo/src"], branches: ["feature/.*"] });
|
||||
expect(useLogOptions.getState()).toMatchObject({ longEdges: true, diffLocation: "bottom" });
|
||||
expect(useLogOptions.getState()).toMatchObject({ showHash: true, diffLocation: "bottom" });
|
||||
expect([...useGitLog.getState().fragments.expanded]).toEqual(["/repo\0expanded"]);
|
||||
expect([...useGitLog.getState().fragments.collapsed]).toEqual(["/repo\0collapsed"]);
|
||||
expect([...useGitLog.getState().fragments.merges]).toEqual(["/repo\0merge"]);
|
||||
|
||||
@@ -86,24 +86,6 @@ export const DEFAULT_LOG_OPTIONS: LogOptions = {
|
||||
/** Options that change which commits the backend returns (a reload is needed). */
|
||||
export const QUERY_OPTIONS: ReadonlyArray<keyof LogOptions> = ["sort", "firstParent", "noMerges"];
|
||||
|
||||
const APPLICATION_LOG_OPTION_KEYS = [
|
||||
"compactRefs",
|
||||
"tagNames",
|
||||
"commitTimestamp",
|
||||
"refsOnLeft",
|
||||
"showAuthor",
|
||||
"showDate",
|
||||
"showHash",
|
||||
"showSignature",
|
||||
"showGitHubChecks",
|
||||
"diffPreview",
|
||||
"changesFromParents",
|
||||
"diffLocation",
|
||||
"columnOrder",
|
||||
] as const satisfies readonly (keyof LogOptions)[];
|
||||
|
||||
export type ApplicationLogOptions = Pick<LogOptions, (typeof APPLICATION_LOG_OPTION_KEYS)[number]>;
|
||||
|
||||
const KEY = "openidea.vcs.logOptions";
|
||||
|
||||
export function parseLogOptions(raw: unknown): LogOptions {
|
||||
@@ -130,20 +112,16 @@ export function parseLogOptions(raw: unknown): LogOptions {
|
||||
return out;
|
||||
}
|
||||
|
||||
function pickApplicationOptions(options: LogOptions): ApplicationLogOptions {
|
||||
return Object.fromEntries(APPLICATION_LOG_OPTION_KEYS.map((key) => [key, options[key]])) as ApplicationLogOptions;
|
||||
}
|
||||
|
||||
function loadApplicationOptions(): ApplicationLogOptions {
|
||||
function load(): LogOptions {
|
||||
try {
|
||||
const raw = localStorage.getItem(KEY);
|
||||
return pickApplicationOptions(parseLogOptions(raw ? JSON.parse(raw) : null));
|
||||
return parseLogOptions(raw ? JSON.parse(raw) : null);
|
||||
} catch {
|
||||
return pickApplicationOptions(DEFAULT_LOG_OPTIONS);
|
||||
return { ...DEFAULT_LOG_OPTIONS };
|
||||
}
|
||||
}
|
||||
|
||||
export const rootLogOptions = create<LogOptions>(() => ({ ...DEFAULT_LOG_OPTIONS, ...loadApplicationOptions() }));
|
||||
export const rootLogOptions = create<LogOptions>(() => load());
|
||||
export const useLogOptions = Object.assign(function useScopedLogOptions<T = LogOptions>(
|
||||
selector?: (state: LogOptions) => T,
|
||||
): T {
|
||||
@@ -151,25 +129,13 @@ export const useLogOptions = Object.assign(function useScopedLogOptions<T = LogO
|
||||
return rootLogOptions((state) => (selector ? selector(scoped ?? state) : ((scoped ?? state) as T)));
|
||||
}, rootLogOptions);
|
||||
|
||||
export function applicationLogOptions(options: LogOptions = rootLogOptions.getState()): ApplicationLogOptions {
|
||||
return pickApplicationOptions(options);
|
||||
}
|
||||
|
||||
export function withApplicationLogOptions(options: Partial<LogOptions>): LogOptions {
|
||||
return { ...DEFAULT_LOG_OPTIONS, ...options, ...applicationLogOptions() };
|
||||
}
|
||||
|
||||
export function setActiveLogOptions(options: Partial<LogOptions>): void {
|
||||
rootLogOptions.setState(withApplicationLogOptions(options));
|
||||
}
|
||||
|
||||
// Settings › Version Control › Log edits them from the Settings window too.
|
||||
if (typeof window !== "undefined")
|
||||
window.addEventListener("storage", (e) => {
|
||||
if (e.key === KEY) rootLogOptions.setState((state) => ({ ...state, ...loadApplicationOptions() }));
|
||||
if (e.key === KEY) useLogOptions.setState(load());
|
||||
});
|
||||
|
||||
export const logOptions = () => rootLogOptions.getState();
|
||||
export const logOptions = () => useLogOptions.getState();
|
||||
|
||||
export type RefKind = "head" | "local" | "remote" | "tag";
|
||||
|
||||
@@ -218,14 +184,13 @@ export function refLabels(
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Updates options and persists application-level properties; returns whether the log has to be reloaded. */
|
||||
/** Updates options and persists them; returns whether the log has to be reloaded. */
|
||||
export function setLogOptions(patch: Partial<LogOptions>): boolean {
|
||||
const before = rootLogOptions.getState();
|
||||
const after = { ...before, ...patch };
|
||||
rootLogOptions.setState(after);
|
||||
const before = useLogOptions.getState();
|
||||
useLogOptions.setState(patch);
|
||||
const after = useLogOptions.getState();
|
||||
try {
|
||||
// Per-tab properties are saved in the log session, not in the application store.
|
||||
localStorage.setItem(KEY, JSON.stringify(applicationLogOptions(after)));
|
||||
localStorage.setItem(KEY, JSON.stringify(after));
|
||||
} catch {
|
||||
// Storage unavailable: the options last for this session.
|
||||
}
|
||||
|
||||
@@ -9,15 +9,7 @@ import { tx } from "@/platform/i18n";
|
||||
import type { Branch, BranchInfo, Commit, LogQuery } from "@/bindings";
|
||||
import { call, commands, nextRequestId, type RequestId } from "@/platform/ipc";
|
||||
import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import {
|
||||
logOptions,
|
||||
parseLogOptions,
|
||||
setActiveLogOptions,
|
||||
setLogOptions,
|
||||
useLogOptions,
|
||||
withApplicationLogOptions,
|
||||
type LogOptions,
|
||||
} from "./logOptions";
|
||||
import { logOptions, parseLogOptions, setLogOptions, useLogOptions, type LogOptions } from "./logOptions";
|
||||
import { clearConsole, errorMessage } from "./ops";
|
||||
import { currentRepo, currentRepoRoot, repoName, repoOf, useVcs } from "./store";
|
||||
import { chooseLogCommit } from "./CommitChooser";
|
||||
@@ -390,7 +382,6 @@ function freshView(filters: LogFilters): LogView {
|
||||
|
||||
/** Views of the log tabs not shown now. */
|
||||
const parked = new Map<string, LogView>();
|
||||
let switchingLogView = false;
|
||||
|
||||
function currentView(): LogView {
|
||||
const {
|
||||
@@ -447,19 +438,12 @@ function setViewState(id: string, patch: Partial<LogState> | ((state: LogState)
|
||||
function showLogView(id: string) {
|
||||
const s = useGitLog.getState();
|
||||
if (s.shownLog === id) return;
|
||||
switchingLogView = true;
|
||||
try {
|
||||
parked.set(s.shownLog, currentView());
|
||||
const view = parked.get(id) ?? freshView(emptyFilters());
|
||||
parked.delete(id);
|
||||
const { options, ...state } = view;
|
||||
useGitLog.setState({ ...state, shownLog: id });
|
||||
setActiveLogOptions(options);
|
||||
} finally {
|
||||
switchingLogView = false;
|
||||
}
|
||||
saveLogSession(useVcs.getState().root);
|
||||
const view = logState(id);
|
||||
parked.set(s.shownLog, currentView());
|
||||
const view = parked.get(id) ?? freshView(emptyFilters());
|
||||
parked.delete(id);
|
||||
const { options, ...state } = view;
|
||||
setLogOptions(options);
|
||||
useGitLog.setState({ ...state, shownLog: id });
|
||||
if (!view.commits.length && !view.done && !view.loading) void reloadLog();
|
||||
}
|
||||
|
||||
@@ -642,7 +626,7 @@ export function installGitLog(): () => void {
|
||||
const comparisons = new Set(logTabs.filter((tab) => tab.comparison).map((tab) => tab.id));
|
||||
for (const [id, view] of parked) {
|
||||
if (comparisons.has(id)) void reloadLog({ preserve: true }, id);
|
||||
else parked.set(id, { ...freshView(view.filters), options: withApplicationLogOptions(view.options) });
|
||||
else parked.set(id, { ...freshView(view.filters), options: view.options });
|
||||
}
|
||||
void reloadLog({ preserve: comparisons.has(shownLog) });
|
||||
}
|
||||
@@ -715,7 +699,7 @@ function parseFilters(value: unknown): LogFilters {
|
||||
}
|
||||
|
||||
function saveLogSession(root: string | null) {
|
||||
if (!root || restoring || switchingLogView) return;
|
||||
if (!root || restoring) return;
|
||||
const state = useGitLog.getState();
|
||||
const views = new Map(parked).set(state.shownLog, currentView());
|
||||
try {
|
||||
@@ -773,7 +757,7 @@ function restoreLogSession(root: string | null) {
|
||||
tabs.find((tab) => tab.id === view.id),
|
||||
),
|
||||
),
|
||||
options: withApplicationLogOptions(parseLogOptions(view.options)),
|
||||
options: parseLogOptions(view.options),
|
||||
fragments: parseFragments(view.fragments),
|
||||
selected: typeof view.selected === "string" ? view.selected : null,
|
||||
selection: Array.isArray(view.selection)
|
||||
@@ -788,7 +772,7 @@ function restoreLogSession(root: string | null) {
|
||||
const view = parked.get(id) ?? freshView(emptyFilters());
|
||||
parked.delete(id);
|
||||
const { options, ...state } = view;
|
||||
setActiveLogOptions(options);
|
||||
setLogOptions(options);
|
||||
const bookmarks =
|
||||
value.bookmarks && typeof value.bookmarks === "object"
|
||||
? Object.fromEntries(
|
||||
|
||||
@@ -57,18 +57,24 @@
|
||||
}
|
||||
.separator {
|
||||
height: 1px;
|
||||
margin: var(--space-1-5) calc(var(--space-1-5) + var(--space-2));
|
||||
margin: 5px 12px;
|
||||
background: var(--border);
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: var(--h-list-row);
|
||||
padding: var(--space-0-5) calc(var(--space-1-5) + var(--space-2));
|
||||
padding: 4px 16px 2px;
|
||||
color: var(--fg-muted);
|
||||
font-size: var(--fs-small);
|
||||
font-weight: 600;
|
||||
}
|
||||
.groupHeader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
padding: 6px 16px 2px;
|
||||
color: var(--fg);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
--icon-color: var(--fg-muted);
|
||||
}
|
||||
.badge {
|
||||
align-self: flex-start;
|
||||
|
||||
@@ -75,7 +75,7 @@ describe("ProjectPopup", () => {
|
||||
expect(within(list).getAllByText("FastAPIProject")).toHaveLength(1);
|
||||
const remoteRow = within(list).getByText("FastAPIProject").closest('[role="option"]')!;
|
||||
expect(remoteRow.querySelector("[data-remote-badge]")).not.toBeNull();
|
||||
expect(remoteRow.textContent).toContain("Ubuntu-24.04:/root/projetos/FastAPIProject");
|
||||
expect(remoteRow.querySelector('[data-remote-kind="wsl"]')?.textContent).toContain("WSL");
|
||||
});
|
||||
|
||||
it("leaves local project avatars and rows free of remote badges", async () => {
|
||||
@@ -96,11 +96,12 @@ describe("ProjectPopup", () => {
|
||||
const rows = screen.getAllByRole("option").filter((r) => r.textContent?.includes("same-name"));
|
||||
expect(rows).toHaveLength(2);
|
||||
expect(rows[0]!.querySelector("[data-remote-badge]")).not.toBeNull();
|
||||
expect(rows[0]!.textContent).toContain("devbox:/home/me/same-name");
|
||||
expect(rows[0]!.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("SSH");
|
||||
expect(rows[1]!.querySelector("[data-remote-badge]")).toBeNull();
|
||||
expect(rows[1]!.querySelector("[data-remote-kind]")).toBeNull();
|
||||
});
|
||||
|
||||
it("lists recent projects in recency order regardless of Welcome groups", async () => {
|
||||
it("lists recent projects under the Welcome screen's groups, collapsed or not, then the ungrouped ones", async () => {
|
||||
open = [{ name: "current", root: "/w/current", current: true, remote: null }];
|
||||
recent = [project("current", 9), project("example-web", 5), project("loose", 4), project("example-api", 3)];
|
||||
groups = [
|
||||
@@ -114,16 +115,14 @@ describe("ProjectPopup", () => {
|
||||
<ProjectPopup anchor={anchor} onClose={() => {}} />
|
||||
</>,
|
||||
);
|
||||
await screen.findByText("Open Projects");
|
||||
await screen.findByText("Recent Projects");
|
||||
await screen.findByText("Frontend");
|
||||
const text = screen.getByRole("listbox").textContent ?? "";
|
||||
const order = ["Recent Projects", "example-web", "loose", "example-api"];
|
||||
const order = ["Recent Projects", "Frontend", "example-web", "Backend", "example-api", "loose"];
|
||||
expect(order.map((t) => text.indexOf(t))).toEqual([...order.map((t) => text.indexOf(t))].sort((a, b) => a - b));
|
||||
expect(order.every((t) => text.includes(t))).toBe(true);
|
||||
// The open project stays under Open Projects only.
|
||||
expect(within(screen.getByRole("listbox")).getAllByText("current")).toHaveLength(1);
|
||||
expect(text).not.toContain("Frontend");
|
||||
expect(text).not.toContain("Backend");
|
||||
expect(screen.getAllByRole("option").map((o) => o.textContent)).not.toContain("Frontend");
|
||||
});
|
||||
|
||||
it("opens a recent project in a new window with Shift or Ctrl, in this one with Alt", async () => {
|
||||
@@ -174,7 +173,7 @@ describe("ProjectPopup", () => {
|
||||
expect(openRecent).toHaveBeenLastCalledWith(exampleWeb, null);
|
||||
});
|
||||
|
||||
it("keeps local and remote projects in a flat recency-ordered list with remote badges", async () => {
|
||||
it("groups Recent Projects by host in MRU order while keeping Open Projects flat", async () => {
|
||||
const sshA = { kind: "ssh", config: "devbox" } as const;
|
||||
const sshB = { kind: "ssh", config: "mbp" } as const;
|
||||
open = [{ name: "openidea_all", root: "/Users/me/git/openidea_all", current: true, remote: null }];
|
||||
@@ -199,25 +198,22 @@ describe("ProjectPopup", () => {
|
||||
const order = [
|
||||
"Open Projects",
|
||||
"Recent Projects",
|
||||
"devbox:/srv/openidea_all",
|
||||
"SSH·devbox",
|
||||
"/srv/openidea_all",
|
||||
"/srv/gocommon",
|
||||
"Local",
|
||||
"~/git/gocommon",
|
||||
"mbp:/Users/dev/gocommon",
|
||||
"devbox:/srv/gocommon",
|
||||
"~/git/superpowers",
|
||||
"SSH·mbp",
|
||||
"/Users/dev/gocommon",
|
||||
];
|
||||
expect(order.every((t) => text.includes(t))).toBe(true);
|
||||
expect(order.map((t) => text.indexOf(t))).toEqual([...order.map((t) => text.indexOf(t))].sort((a, b) => a - b));
|
||||
expect(text).not.toContain("Local");
|
||||
const remoteRow = within(list).getByText("devbox:/srv/openidea_all").closest('[role="option"]')!;
|
||||
expect(remoteRow.querySelector("[data-remote-badge]")).not.toBeNull();
|
||||
const localRow = within(list).getByText("~/git/gocommon").closest('[role="option"]')!;
|
||||
expect(localRow.querySelector("[data-remote-badge]")).toBeNull();
|
||||
for (const key of "devbox") fireEvent.keyDown(list, { key });
|
||||
const matches = within(list).getAllByRole("option");
|
||||
expect(matches).toHaveLength(2);
|
||||
for (const row of matches) {
|
||||
expect(row.querySelector("[data-remote-badge]")).not.toBeNull();
|
||||
expect(row.querySelector("mark")?.textContent).toBe("devbox");
|
||||
}
|
||||
// Rows inside a host group omit the duplicate per-row host pill; typing to filter flattens and restores it.
|
||||
const groupedRemote = within(list).getByText("/srv/openidea_all").closest('[role="option"]')!;
|
||||
expect(groupedRemote.querySelector('[data-remote-kind="ssh"]')).toBeNull();
|
||||
fireEvent.keyDown(list, { key: "g" });
|
||||
const searchedRemote = within(list).getByText("/srv/gocommon").closest('[role="option"]')!;
|
||||
expect(searchedRemote.querySelector('[data-remote-kind="ssh"]')?.textContent).toContain("devbox");
|
||||
});
|
||||
});
|
||||
@@ -4,8 +4,25 @@ import { executeAction, useActions } from "@/platform/actions";
|
||||
import { call, commands, isTauri, type OpenProject, type RecentProject } from "@/platform/ipc";
|
||||
import { HighlightedText, Icon, Popup, showContextMenu, type IconName, T } from "@/ui";
|
||||
import type { ProjectPopupProps } from "@/workbench/contributions";
|
||||
import { askRemoveRecent, ProjectBadge, projectAppearanceMenu, recentMenu, unavailableTitle } from "./RecentList";
|
||||
import { filterRecent, loadRecent, openRecent, useRecent, type RecentMatch } from "./recent";
|
||||
import {
|
||||
askRemoveRecent,
|
||||
HostGroupTitle,
|
||||
ProjectBadge,
|
||||
projectAppearanceMenu,
|
||||
recentMenu,
|
||||
RemoteHostPill,
|
||||
splitRemoteMatch,
|
||||
unavailableTitle,
|
||||
} from "./RecentList";
|
||||
import {
|
||||
filterRecent,
|
||||
loadRecent,
|
||||
openRecent,
|
||||
recentRows,
|
||||
useRecent,
|
||||
type HostGroup,
|
||||
type RecentMatch,
|
||||
} from "./recent";
|
||||
import styles from "./ProjectPopup.module.css";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { parseRemoteLocation, remoteLocation } from "@/platform/remote";
|
||||
@@ -13,7 +30,7 @@ import { projectWindowOverride, type ProjectWindowOverride } from "@/workbench/p
|
||||
|
||||
type Entry =
|
||||
| { kind: "action"; id: string; label: string; icon: IconName }
|
||||
| { kind: "project"; open: boolean; m: RecentMatch };
|
||||
| { kind: "project"; open: boolean; m: RecentMatch; group?: string | null; hostGroup?: HostGroup | null };
|
||||
|
||||
const ACTIONS: { id: string; label: string; icon: IconName }[] = [
|
||||
{ id: "file.newProject", label: "New Project…", icon: "plus" },
|
||||
@@ -38,11 +55,13 @@ function useOpenProjects(): OpenProject[] {
|
||||
}
|
||||
|
||||
/**
|
||||
* The title bar project widget's popup: actions, open projects and a flat recent list; type to filter.
|
||||
* The title bar project widget's popup, after IDEA's ProjectWidget: actions, open projects, recent
|
||||
* projects (under the Welcome screen's project groups, then the ungrouped ones); type to filter.
|
||||
*/
|
||||
export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
|
||||
const actions = useActions((s) => s.actions);
|
||||
const recent = useRecent((s) => s.projects);
|
||||
const groups = useRecent((s) => s.groups);
|
||||
const home = useRecent((s) => s.home);
|
||||
const openProjects = useOpenProjects();
|
||||
const [query, setQuery] = useState("");
|
||||
@@ -63,14 +82,22 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
|
||||
open: true,
|
||||
m,
|
||||
}));
|
||||
const rest = filterRecent(
|
||||
// Every group lists its projects here, collapsed on the Welcome screen or not; a search is flat.
|
||||
const expanded = groups.map((g) => ({ ...g, expanded: true }));
|
||||
const rest = recentRows(
|
||||
recent.filter((r) => !openPaths.has(r.path)),
|
||||
expanded,
|
||||
query,
|
||||
home,
|
||||
).map((m) => ({ kind: "project" as const, open: false, m }));
|
||||
[],
|
||||
).flatMap((r) =>
|
||||
r.kind === "project"
|
||||
? [{ kind: "project" as const, open: false, m: r.m, group: r.group, hostGroup: r.hostGroup ?? null }]
|
||||
: [],
|
||||
);
|
||||
const acts = query ? [] : ACTIONS.filter((a) => actions.has(a.id)).map((a) => ({ kind: "action" as const, ...a }));
|
||||
return [...acts, ...open, ...rest];
|
||||
}, [actions, recent, home, openProjects, query]);
|
||||
}, [actions, recent, groups, home, openProjects, query]);
|
||||
const current = Math.min(active, entries.length - 1);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -155,6 +182,7 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
|
||||
<T>Recent Projects</T>
|
||||
</Header>
|
||||
)}
|
||||
{e.kind === "project" && !e.open && <GroupBoundary entry={e} previous={entries[i - 1]} />}
|
||||
<div
|
||||
role="option"
|
||||
aria-selected={i === current}
|
||||
@@ -180,7 +208,7 @@ export function ProjectPopup({ anchor, onClose }: ProjectPopupProps) {
|
||||
<span className={styles.label}>{tx(e.label)}</span>
|
||||
</>
|
||||
) : (
|
||||
<ProjectRow m={e.m} active={i === current} />
|
||||
<ProjectRow m={e.m} active={i === current} hideHost={!e.open && e.hostGroup != null} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -204,7 +232,46 @@ function Header({ first, children }: { first: boolean; children: ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectRow({ m, active }: { m: RecentMatch; active: boolean }) {
|
||||
function sectionKey(entry: Entry | undefined): string | null {
|
||||
if (entry?.kind !== "project" || entry.open) return null;
|
||||
if (entry.group) return `group:${entry.group}`;
|
||||
if (entry.hostGroup) return `host:${entry.hostGroup.id}`;
|
||||
return null;
|
||||
}
|
||||
|
||||
/** A project or host group's name above its first project; a separator where sections change. */
|
||||
function GroupBoundary({
|
||||
entry,
|
||||
previous,
|
||||
}: {
|
||||
entry: Extract<Entry, { kind: "project" }>;
|
||||
previous: Entry | undefined;
|
||||
}) {
|
||||
const prevRecent = previous?.kind === "project" && !previous.open;
|
||||
const before = sectionKey(previous);
|
||||
const current = sectionKey(entry);
|
||||
if (current === before) return null;
|
||||
if (current === null) return <div className={styles.separator} role="separator" />;
|
||||
return (
|
||||
<>
|
||||
{prevRecent && <div className={styles.separator} role="separator" />}
|
||||
<div className={styles.groupHeader}>
|
||||
{entry.group ? (
|
||||
<>
|
||||
<Icon name="folder" size={14} />
|
||||
<span className={styles.label}>{entry.group}</span>
|
||||
</>
|
||||
) : (
|
||||
entry.hostGroup && <HostGroupTitle host={entry.hostGroup} iconSize={14} />
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ProjectRow({ m, active, hideHost }: { m: RecentMatch; active: boolean; hideHost?: boolean }) {
|
||||
const { hostMatch, locationMatch, locationText } = splitRemoteMatch(m);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ProjectBadge
|
||||
@@ -220,7 +287,8 @@ function ProjectRow({ m, active }: { m: RecentMatch; active: boolean }) {
|
||||
indices={m.nameMatch}
|
||||
tone={active ? "accent" : "strong"}
|
||||
/>
|
||||
<HighlightedText className={styles.path} text={m.displayPath} indices={m.pathMatch} />
|
||||
{!hideHost && m.remote && <RemoteHostPill remote={m.remote} hostMatch={hostMatch} />}
|
||||
<HighlightedText className={styles.path} text={locationText} indices={locationMatch} />
|
||||
{m.project.branch && (
|
||||
<span className={styles.metadata}>
|
||||
<Icon name="branch" size={12} />
|
||||
|
||||
@@ -233,8 +233,6 @@ export const EDITOR_EXTRA_DEFAULTS = {
|
||||
smartIndent: true,
|
||||
insertDocStub: true,
|
||||
backspaceUnindent: "autoindent",
|
||||
/** The styles Cycle Identifier Case goes through. */
|
||||
cycleCase: { snake: true, screaming: true, kebab: true, camel: true, pascal: true },
|
||||
},
|
||||
codeEditing: {
|
||||
highlightUsages: true,
|
||||
|
||||
@@ -284,8 +284,6 @@ describe("catalogs", () => {
|
||||
const OWN_SCRIPT = new Set(["zh", "ko"]);
|
||||
/** Product names intentionally kept as written in every locale. */
|
||||
const SAME_AS_ENGLISH = new Set([
|
||||
"SCREAMING_SNAKE_CASE",
|
||||
"camelCase",
|
||||
// PostgreSQL storage parameters, the placeholder of Modify Table's Storage options field.
|
||||
"fillfactor=70, autovacuum_enabled=false",
|
||||
// The placeholder of an Xcode run configuration's project or workspace field.
|
||||
|
||||
@@ -109,7 +109,6 @@ export const IDEA_ACTIONS: Readonly<Record<string, string>> = {
|
||||
SaveAs: "file.saveAs",
|
||||
SaveAll: "file.save",
|
||||
ShowSettings: "file.settings",
|
||||
CopySettingsPath: "settings.copyPath",
|
||||
NewScratchFile: "file.newScratchFile",
|
||||
NewScratchBuffer: "file.newScratchBuffer",
|
||||
CloseContent: "editor.closeTab",
|
||||
@@ -136,7 +135,6 @@ export const IDEA_ACTIONS: Readonly<Record<string, string>> = {
|
||||
EditorScrollDown: "editor.scrollDown",
|
||||
EditorScrollLeft: "editor.scrollLeft",
|
||||
EditorScrollRight: "editor.scrollRight",
|
||||
ScrollTreeToCenter: "tree.scrollToCenter",
|
||||
EditorScrollUpAndMove: "editor.scrollUpAndMove",
|
||||
EditorScrollDownAndMove: "editor.scrollDownAndMove",
|
||||
EditorMoveUpAndScroll: "editor.moveUpAndScroll",
|
||||
@@ -166,7 +164,6 @@ export const IDEA_ACTIONS: Readonly<Record<string, string>> = {
|
||||
EditorToggleShowLineNumbers: "editor.toggleLocalLineNumbers",
|
||||
EditorToggleShowGutterIcons: "editor.toggleLocalGutterIcons",
|
||||
EditorToggleShowIndentLines: "editor.toggleLocalIndentGuides",
|
||||
EditorToggleShowBreadcrumbs: "editor.toggleBreadcrumbs",
|
||||
EditorStickyLinesDisableForLang: "editor.disableStickyLinesForLanguage",
|
||||
ActivateProjectToolWindow: "toolwindow.project",
|
||||
HideAllWindows: "toolwindow.hideAll",
|
||||
|
||||
@@ -8,7 +8,6 @@ describe("IDEA keymap parity", () => {
|
||||
["code.splitLine", ["Meta+Enter"], ["Ctrl+Enter"]],
|
||||
["code.smartTypeCompletion", ["Ctrl+Shift+Space"], ["Ctrl+Shift+Space"]],
|
||||
["editor.scrollToCenter", ["Ctrl+L"], ["Ctrl+M"]],
|
||||
["tree.scrollToCenter", [], []],
|
||||
["editor.codeBlockStart", ["Meta+Alt+["], ["Ctrl+["]],
|
||||
["editor.codeBlockEnd", ["Meta+Alt+]"], ["Ctrl+]"]],
|
||||
["view.zoomIn", ["Ctrl+Alt+="], ["Alt+Shift+="]],
|
||||
@@ -108,7 +107,6 @@ describe("IDEA keymap parity", () => {
|
||||
["editor.toggleLocalWhitespaces", [], []],
|
||||
["editor.toggleLocalGutterIcons", [], []],
|
||||
["editor.toggleLocalIndentGuides", [], []],
|
||||
["editor.toggleBreadcrumbs", [], []],
|
||||
// CopyAsPlainText / CopyAsRichText have no shortcut.
|
||||
["code.copyAsPlainText", [], []],
|
||||
["code.copyAsRichText", [], []],
|
||||
@@ -165,7 +163,6 @@ describe("IDEA keymap parity", () => {
|
||||
["navigate.back", ["Meta+[", "Meta+Alt+Left", "Button4", "SwipeRight"], ["Ctrl+Alt+Left", "Button4"]],
|
||||
["navigate.forward", ["Meta+]", "Meta+Alt+Right", "Button5", "SwipeLeft"], ["Ctrl+Alt+Right", "Button5"]],
|
||||
["file.saveAs", ["Meta+Shift+S"], ["Ctrl+Shift+S"]],
|
||||
["settings.copyPath", [], []],
|
||||
["file.projectStructure", ["Meta+;"], ["Ctrl+Alt+Shift+S"]],
|
||||
["build.compileFile", ["Meta+Shift+F9"], ["Ctrl+Shift+F9"]],
|
||||
["build.buildModule", [], []],
|
||||
|
||||
@@ -142,7 +142,6 @@ export const intellijMacos: Record<string, string[]> = {
|
||||
// Before the HTTP / SQL consoles' ⌘↵ (Run), which wins there.
|
||||
"code.splitLine": ["Meta+Enter"],
|
||||
"editor.scrollToCenter": ["Ctrl+L"],
|
||||
"tree.scrollToCenter": [],
|
||||
"editor.scrollUp": [],
|
||||
"editor.scrollDown": [],
|
||||
"editor.scrollLeft": [],
|
||||
@@ -234,7 +233,6 @@ export const intellijMacos: Record<string, string[]> = {
|
||||
"file.saveAs": ["Meta+Shift+S"],
|
||||
"file.save": ["Meta+S"],
|
||||
"file.settings": ["Meta+,"],
|
||||
"settings.copyPath": [],
|
||||
"file.projectStructure": ["Meta+;"],
|
||||
"file.openProject": ["Meta+Shift+Alt+O"],
|
||||
"file.newScratchFile": ["Meta+Shift+N"],
|
||||
@@ -328,7 +326,6 @@ export const intellijMacos: Record<string, string[]> = {
|
||||
"editor.toggleLocalWhitespaces": [],
|
||||
"editor.toggleLocalGutterIcons": [],
|
||||
"editor.toggleLocalIndentGuides": [],
|
||||
"editor.toggleBreadcrumbs": [],
|
||||
|
||||
// Build
|
||||
"build.buildProject": ["Meta+F9"],
|
||||
|
||||
@@ -143,7 +143,6 @@ export const intellijWindows: Record<string, string[]> = {
|
||||
// Before the HTTP / SQL consoles' Ctrl+Enter (Run), which wins there.
|
||||
"code.splitLine": ["Ctrl+Enter"],
|
||||
"editor.scrollToCenter": ["Ctrl+M"],
|
||||
"tree.scrollToCenter": [],
|
||||
"editor.scrollUp": ["Ctrl+Up"],
|
||||
"editor.scrollDown": ["Ctrl+Down"],
|
||||
"editor.scrollLeft": [],
|
||||
@@ -235,7 +234,6 @@ export const intellijWindows: Record<string, string[]> = {
|
||||
"file.saveAs": ["Ctrl+Shift+S"],
|
||||
"file.save": ["Ctrl+S"],
|
||||
"file.settings": ["Ctrl+Alt+S"],
|
||||
"settings.copyPath": [],
|
||||
"file.projectStructure": ["Ctrl+Alt+Shift+S"],
|
||||
"file.openProject": [],
|
||||
"file.newScratchFile": ["Ctrl+Alt+Shift+Insert"],
|
||||
@@ -322,7 +320,6 @@ export const intellijWindows: Record<string, string[]> = {
|
||||
"editor.toggleLocalWhitespaces": [],
|
||||
"editor.toggleLocalGutterIcons": [],
|
||||
"editor.toggleLocalIndentGuides": [],
|
||||
"editor.toggleBreadcrumbs": [],
|
||||
|
||||
// Build
|
||||
"build.buildProject": ["Ctrl+F9"],
|
||||
|
||||
@@ -229,7 +229,6 @@ export const vscodeMacos: Record<string, string[]> = {
|
||||
"file.newUntitled": ["Meta+N"],
|
||||
"file.new": [],
|
||||
"file.settings": ["Meta+,"],
|
||||
"settings.copyPath": [],
|
||||
"file.projectStructure": [],
|
||||
"file.openProject": ["Meta+O"],
|
||||
"file.newScratchFile": [],
|
||||
@@ -258,7 +257,6 @@ export const vscodeMacos: Record<string, string[]> = {
|
||||
"editor.toggleLocalWhitespaces": [],
|
||||
"editor.toggleLocalGutterIcons": [],
|
||||
"editor.toggleLocalIndentGuides": [],
|
||||
"editor.toggleBreadcrumbs": [],
|
||||
"window.toggleFullScreen": ["Meta+Ctrl+F"],
|
||||
// Project window groups are an IntelliJ concept; VS Code has no counterpart.
|
||||
"window.nextTab": [],
|
||||
@@ -270,7 +268,6 @@ export const vscodeMacos: Record<string, string[]> = {
|
||||
"navigate.searchText": [],
|
||||
"code.splitLine": [],
|
||||
"editor.scrollToCenter": [],
|
||||
"tree.scrollToCenter": [],
|
||||
"editor.scrollUp": [],
|
||||
"editor.scrollDown": [],
|
||||
"editor.scrollLeft": [],
|
||||
|
||||
@@ -705,7 +705,6 @@
|
||||
"Start New Line Before Current": "在目前行前開始新行",
|
||||
"Split Line": "拆分行",
|
||||
"Scroll to Center": "捲動到中央",
|
||||
"Scroll Tree to Center": "將樹選取項目捲動到中央",
|
||||
"Scroll Up": "向上捲動",
|
||||
"Scroll Down": "向下捲動",
|
||||
"Scroll Left": "向左捲動",
|
||||
@@ -1246,8 +1245,6 @@
|
||||
"Copy Original Text": "複製原始文字",
|
||||
"Original text": "原始文字",
|
||||
"Copy Path": "複製路徑",
|
||||
"Copy Settings Path": "複製設定路徑",
|
||||
"Copy the relative path to the selected configurable option": "複製所選可設定項的相對路徑",
|
||||
"Copy Path from Project Root": "複製專案根目錄起的路徑",
|
||||
"Copy Path/Reference…": "複製路徑/引用…",
|
||||
"Copy directory '{sourceName}'": "複製目錄「{sourceName}」",
|
||||
@@ -3036,8 +3033,6 @@
|
||||
"Soft Wraps": "軟換行",
|
||||
"Soft-Wrap": "軟換行",
|
||||
"Show Line Numbers": "顯示行號",
|
||||
"Show Breadcrumbs": "顯示麵包屑",
|
||||
"Toggle display of the Breadcrumbs bar in the current editor.": "切換目前編輯器中麵包屑列的顯示。",
|
||||
"Show Indent Guides": "顯示縮排參考線",
|
||||
"Disable Sticky Lines for Language": "為目前語言停用粘滯行",
|
||||
"Disable sticky lines for the current document's language without changing the global setting.": "為目前文件的語言停用粘滯行,不變更全域設定。",
|
||||
|
||||
@@ -1155,7 +1155,6 @@
|
||||
"Start New Line Before Current": "在当前行前开始新行",
|
||||
"Split Line": "拆分行",
|
||||
"Scroll to Center": "滚动到中央",
|
||||
"Scroll Tree to Center": "将树选择滚动到中央",
|
||||
"Scroll Up": "向上滚动",
|
||||
"Scroll Down": "向下滚动",
|
||||
"Scroll Left": "向左滚动",
|
||||
@@ -1189,8 +1188,6 @@
|
||||
"Join Lines": "合并行",
|
||||
"Toggle Case": "切换大小写",
|
||||
"Cycle Identifier Case": "循环切换标识符大小写",
|
||||
"SCREAMING_SNAKE_CASE": "SCREAMING_SNAKE_CASE",
|
||||
"camelCase": "camelCase",
|
||||
"Add or Remove Caret": "添加或移除插入点",
|
||||
"Create Rectangular Selection on Mouse Drag": "拖动鼠标创建矩形选区",
|
||||
"Middle Click": "鼠标中键",
|
||||
@@ -1740,8 +1737,6 @@
|
||||
"Copy Original Text": "复制原始文本",
|
||||
"Original text": "原始文本",
|
||||
"Copy Path": "复制路径",
|
||||
"Copy Settings Path": "复制设置路径",
|
||||
"Copy the relative path to the selected configurable option": "复制所选可配置项的相对路径",
|
||||
"Copy Path from Project Root": "复制项目根目录起的路径",
|
||||
"Copy Path/Reference…": "复制路径/引用…",
|
||||
"Copy directory '{sourceName}'": "复制目录“{sourceName}”",
|
||||
@@ -3703,8 +3698,6 @@
|
||||
"Soft Wraps": "软换行",
|
||||
"Soft-Wrap": "软换行",
|
||||
"Show Line Numbers": "显示行号",
|
||||
"Show Breadcrumbs": "显示面包屑",
|
||||
"Toggle display of the Breadcrumbs bar in the current editor.": "切换当前编辑器中面包屑栏的显示。",
|
||||
"Show Gutter Icons": "显示 Gutter 图标",
|
||||
"Show Indent Guides": "显示缩进参考线",
|
||||
"Disable Sticky Lines for Language": "为当前语言禁用粘滞行",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { beforeAll, afterAll, describe, expect, it, vi } from "vitest";
|
||||
import { createRef } from "react";
|
||||
import { act, fireEvent, render, screen, within } from "@testing-library/react";
|
||||
import { scrollFocusedTreeToCenter, Tree, type TreeHandle } from "./Tree";
|
||||
import { Tree, type TreeHandle } from "./Tree";
|
||||
import { getContext } from "@/platform/context";
|
||||
import { registerAction } from "@/platform/actions";
|
||||
import { installKeyboardDispatcher, useKeymap } from "@/platform/keymap";
|
||||
@@ -661,22 +661,6 @@ describe("Tree scroll following", () => {
|
||||
expect(scrollTo).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("centers the focused tree's selection without changing it", () => {
|
||||
const { tree, key, lead } = setup({ defaultSelected: ["README.md"] });
|
||||
key("End");
|
||||
expect(lead()).toBe("README.md");
|
||||
expect(document.activeElement).toBe(tree);
|
||||
expect(getContext().treeFocus).toBe(true);
|
||||
scrollTo.mockClear();
|
||||
scrollFocusedTreeToCenter();
|
||||
expect(scrollTo).toHaveBeenCalledTimes(1);
|
||||
expect(lead()).toBe("README.md");
|
||||
fireEvent.blur(tree);
|
||||
scrollTo.mockClear();
|
||||
scrollFocusedTreeToCenter();
|
||||
expect(scrollTo).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("brings speed search matches into view", () => {
|
||||
const { key, lead } = setup({ defaultExpanded: ["src", "main"] });
|
||||
key("Home");
|
||||
|
||||
+56
-84
@@ -76,8 +76,6 @@ export interface TreeHandle {
|
||||
reveal(key: string): boolean;
|
||||
/** Scrolls the row with `key` into view without changing the selection. */
|
||||
scrollIntoView(key: string): void;
|
||||
/** Centers the selected lead row without changing the selection. */
|
||||
centerSelection(): void;
|
||||
clearSelection(): void;
|
||||
leadKey(): string | null;
|
||||
/** Selects the next (1) / previous (-1) row, for a filter field that keeps the focus (Settings search). */
|
||||
@@ -91,15 +89,6 @@ export interface TreeHandle {
|
||||
selectOccurrence(dir: 1 | -1, options?: { skipSubtree?: boolean }): TreeOccurrence | null;
|
||||
}
|
||||
|
||||
const focusedTrees = new WeakMap<HTMLElement, TreeHandle>();
|
||||
let focusedTree: HTMLElement | null = null;
|
||||
|
||||
/** IDEA's Scroll Tree to Center: the focused tree's selected row, without selecting anything else. */
|
||||
export function scrollFocusedTreeToCenter(): void {
|
||||
const handle = focusedTree ? focusedTrees.get(focusedTree) : null;
|
||||
handle?.centerSelection();
|
||||
}
|
||||
|
||||
export interface TreeProps<T> {
|
||||
roots: readonly T[];
|
||||
getKey: (node: T) => string;
|
||||
@@ -328,7 +317,6 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
const [onlyMatches, setOnlyMatches] = useState(false);
|
||||
const filterMatches = speedSearchMode === "filter" || (speedSearchField && onlyMatches);
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const localHandleRef = useRef<TreeHandle | null>(null);
|
||||
const baseId = useId();
|
||||
|
||||
const allRows = useMemo(() => {
|
||||
@@ -532,69 +520,60 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
}
|
||||
};
|
||||
|
||||
useImperativeHandle(handleRef ?? localHandleRef, () => {
|
||||
const handle: TreeHandle = {
|
||||
focus: () => scrollRef.current?.focus(),
|
||||
reveal: (key: string) => {
|
||||
const i = indexOfKey.get(key);
|
||||
if (i === undefined) return false;
|
||||
setAnchor(key);
|
||||
commitSelection(new Set([key]), key);
|
||||
virtualizer.scrollToIndex(i, { align: "center" });
|
||||
return true;
|
||||
},
|
||||
scrollIntoView: (key: string) => {
|
||||
const i = indexOfKey.get(key);
|
||||
if (i !== undefined) virtualizer.scrollToIndex(i, { align: "auto" });
|
||||
},
|
||||
centerSelection: () => {
|
||||
const i = lead != null ? indexOfKey.get(lead) : -1;
|
||||
if (i !== undefined && i >= 0) virtualizer.scrollToIndex(i, { align: "center" });
|
||||
},
|
||||
clearSelection: () => {
|
||||
setAnchor(null);
|
||||
commitSelection(new Set(), null);
|
||||
},
|
||||
leadKey: () => lead,
|
||||
moveSelection: (dir: 1 | -1) => {
|
||||
const key = lead != null && selected.has(lead) ? lead : ([...selected][0] ?? null);
|
||||
const from = key != null ? (indexOfKey.get(key) ?? -1) : -1;
|
||||
const i = from < 0 ? step(-1, 1) : step(from, dir);
|
||||
if (i < 0 || i === from || !rows[i]) return;
|
||||
selectIndex(i);
|
||||
virtualizer.scrollToIndex(i);
|
||||
},
|
||||
selectOccurrence: (dir: 1 | -1, options?: { skipSubtree?: boolean }) => {
|
||||
const found = findOccurrence(
|
||||
roots,
|
||||
lead,
|
||||
dir,
|
||||
{ getKey, getChildren, isExpandable, isOccurrence: props.isOccurrence },
|
||||
options?.skipSubtree,
|
||||
);
|
||||
if (!found) return null;
|
||||
const missing = found.ancestors.filter((a) => !expanded.has(getKey(a)));
|
||||
if (missing.length) {
|
||||
const next = new Set(expanded);
|
||||
for (const a of missing) {
|
||||
next.add(getKey(a));
|
||||
props.onExpandedChange?.(new Set(next), a, true);
|
||||
}
|
||||
if (!expandedControlled) setExpandedInner(next);
|
||||
useImperativeHandle(handleRef, () => ({
|
||||
focus: () => scrollRef.current?.focus(),
|
||||
reveal: (key: string) => {
|
||||
const i = indexOfKey.get(key);
|
||||
if (i === undefined) return false;
|
||||
setAnchor(key);
|
||||
commitSelection(new Set([key]), key);
|
||||
virtualizer.scrollToIndex(i, { align: "center" });
|
||||
return true;
|
||||
},
|
||||
scrollIntoView: (key: string) => {
|
||||
const i = indexOfKey.get(key);
|
||||
if (i !== undefined) virtualizer.scrollToIndex(i, { align: "auto" });
|
||||
},
|
||||
clearSelection: () => {
|
||||
setAnchor(null);
|
||||
commitSelection(new Set(), null);
|
||||
},
|
||||
leadKey: () => lead,
|
||||
moveSelection: (dir: 1 | -1) => {
|
||||
const key = lead != null && selected.has(lead) ? lead : ([...selected][0] ?? null);
|
||||
const from = key != null ? (indexOfKey.get(key) ?? -1) : -1;
|
||||
const i = from < 0 ? step(-1, 1) : step(from, dir);
|
||||
if (i < 0 || i === from || !rows[i]) return;
|
||||
selectIndex(i);
|
||||
virtualizer.scrollToIndex(i);
|
||||
},
|
||||
selectOccurrence: (dir: 1 | -1, options?: { skipSubtree?: boolean }) => {
|
||||
const found = findOccurrence(
|
||||
roots,
|
||||
lead,
|
||||
dir,
|
||||
{ getKey, getChildren, isExpandable, isOccurrence: props.isOccurrence },
|
||||
options?.skipSubtree,
|
||||
);
|
||||
if (!found) return null;
|
||||
const missing = found.ancestors.filter((a) => !expanded.has(getKey(a)));
|
||||
if (missing.length) {
|
||||
const next = new Set(expanded);
|
||||
for (const a of missing) {
|
||||
next.add(getKey(a));
|
||||
props.onExpandedChange?.(new Set(next), a, true);
|
||||
}
|
||||
const key = getKey(found.node);
|
||||
const sel = new Set([key]);
|
||||
setAnchor(key);
|
||||
if (!selectedControlled) setSelectedInner(sel);
|
||||
setLead(key);
|
||||
props.onSelectionChange?.(sel, found.node);
|
||||
return { key, node: found.node, index: found.index, total: found.total };
|
||||
},
|
||||
};
|
||||
const element = scrollRef.current;
|
||||
if (element) focusedTrees.set(element, handle);
|
||||
return handle;
|
||||
});
|
||||
if (!expandedControlled) setExpandedInner(next);
|
||||
}
|
||||
const key = getKey(found.node);
|
||||
const sel = new Set([key]);
|
||||
setAnchor(key);
|
||||
if (!selectedControlled) setSelectedInner(sel);
|
||||
setLead(key);
|
||||
props.onSelectionChange?.(sel, found.node);
|
||||
return { key, node: found.node, index: found.index, total: found.total };
|
||||
},
|
||||
}));
|
||||
|
||||
const findMatch = (from: number, dir: 1 | -1, inclusive: boolean, q = query, wrap = true): number => {
|
||||
if (!q) return -1;
|
||||
@@ -794,22 +773,16 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
const { focusContext } = props;
|
||||
useLayoutEffect(() => {
|
||||
const element = scrollRef.current;
|
||||
if (!element) return;
|
||||
if (!focusContext || !element) return;
|
||||
let focused = false;
|
||||
const focus = () => {
|
||||
focused = true;
|
||||
focusedTree = element;
|
||||
setContext("treeFocus", true);
|
||||
if (focusContext) setContext(focusContext, true);
|
||||
setContext(focusContext, true);
|
||||
};
|
||||
const blur = () => {
|
||||
if (!focused) return;
|
||||
focused = false;
|
||||
if (focusedTree === element) {
|
||||
focusedTree = null;
|
||||
setContext("treeFocus", false);
|
||||
}
|
||||
if (focusContext) setContext(focusContext, false);
|
||||
setContext(focusContext, false);
|
||||
};
|
||||
element.addEventListener("focus", focus);
|
||||
element.addEventListener("blur", blur);
|
||||
@@ -817,7 +790,6 @@ export function Tree<T>(props: TreeProps<T>) {
|
||||
return () => {
|
||||
element.removeEventListener("focus", focus);
|
||||
element.removeEventListener("blur", blur);
|
||||
focusedTrees.delete(element);
|
||||
// Removing a focused tree can skip blur, leaving its shortcuts active.
|
||||
blur();
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ import { registerAction, registerActions, retitleAction, type Action } from "@/p
|
||||
import { setContext } from "@/platform/context";
|
||||
import { formatMessage, tx } from "@/platform/i18n";
|
||||
import { occurrenceNavigator, showStatusInfo, useContributions } from "../contributions";
|
||||
import { scrollFocusedTreeToCenter } from "@/ui/Tree";
|
||||
import { isDistractionFree, setDistractionFree } from "../distractionFree";
|
||||
import { focusEditor } from "../focus";
|
||||
import { chooseItem, promptInput } from "../inputDialogs";
|
||||
@@ -277,14 +276,6 @@ export function installToolWindowActions(): () => void {
|
||||
when: "toolWindowFocus && !popupOpen",
|
||||
run: () => focusEditor(),
|
||||
},
|
||||
{
|
||||
id: "tree.scrollToCenter",
|
||||
title: "Scroll Tree to Center",
|
||||
category: "Navigate",
|
||||
keywords: ["tree", "selection", "scroll to center"],
|
||||
when: "treeFocus && !popupOpen",
|
||||
run: () => scrollFocusedTreeToCenter(),
|
||||
},
|
||||
{
|
||||
id: "navigate.nextOccurrence",
|
||||
title: "Next Occurrence",
|
||||
|
||||
Reference in new issue
Заблокувати користувача