Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 25c75def03 fix(search): show tool window names in the UI language in Recent Files
The tool-window column of Recent Files / Switcher listed every window by its
English title in a localized UI; the window's own header translates it. Recent
Files, the Run configuration's Activate tool window task and its menu now use the
same translated title (plugin windows keep theirs), and the English name still
finds a translated window when typed.

Fixes #3931
2026-11-17 19:37:21 +08:00
7 змінених файлів з 62 додано та 27 видалено

No files matched your search

+8 -2
Переглянути файл
@@ -49,6 +49,7 @@ import { EnvDialog } from "./EnvDialog";
import { useBuildModel } from "@/platform/buildModel";
import { COMPOUND, formParams, terminalApplies, withParams } from "./types";
import { TomcatSettings } from "./TomcatSettings";
import { toolWindowTitle } from "@/workbench/toolwindows/title";
import styles from "./Run.module.css";
/**
@@ -363,8 +364,13 @@ export function ConfigForm({ config, all, type, errors, template, onChange, modi
{
label: TASK_LABELS.toolWindow,
submenu: [...toolWindows.values()]
.sort((a, b) => a.title.localeCompare(b.title))
.map((w) => ({ label: w.title, icon: w.icon, run: () => addTask("toolWindow", w.id) })),
.map((w) => ({
label: toolWindowTitle(w),
verbatim: true,
icon: w.icon,
run: () => addTask("toolWindow", w.id),
}))
.sort((a, b) => a.label.localeCompare(b.label)),
},
];
const moveTask = (i: number, d: -1 | 1) => {
+5 -2
Переглянути файл
@@ -13,6 +13,7 @@ import type { BeforeLaunchTask, RunConfig } from "@/platform/ipc";
import { workflowSettings } from "@/platform/workflowSettings";
import { notifications, toolWindowService, useContributions } from "@/workbench/contributions";
import { externalToolConfig } from "./externalTools";
import { toolWindowTitle } from "@/workbench/toolwindows/title";
import { startRun, useRun } from "./store";
export const BUILD_ACTION = "build.buildProject";
@@ -56,8 +57,10 @@ export function taskLabel(task: BeforeLaunchTask, configs: readonly RunConfig[]
return `External tool '${workflowSettings().externalTools.find((t) => t.id === target)?.name ?? target}'`;
case "command":
return target ? `Run '${target}'` : "Run shell command";
case "toolWindow":
return `Activate '${useContributions.getState().toolWindows.get(target)?.title ?? target}' tool window`;
case "toolWindow": {
const tw = useContributions.getState().toolWindows.get(target);
return `Activate '${tw ? toolWindowTitle(tw) : target}' tool window`;
}
default:
return task.kind;
}
+19
Переглянути файл
@@ -7,6 +7,7 @@ import {
renameLocations,
type RecentLocation,
} from "../common/locations";
import { useI18n } from "@/platform/i18n";
import {
filterLocations,
filterRecentFiles,
@@ -194,6 +195,24 @@ describe("recent files switcher", () => {
expect(switcherToolWindows(list, true, "ter").map((x) => x.tw.id)).toEqual(["terminal"]);
expect(switcherToolWindows(list, false, "")).toEqual([]);
});
it("lists tool windows by their title in the UI language and still finds them by the English one", () => {
const previous = useI18n.getState().texts;
useI18n.setState({ texts: { ...previous, Terminal: "终端" } });
try {
const tw = (id: string, title: string, extra: Partial<ToolWindowContribution> = {}) =>
({ id, title, icon: "folder", anchor: "bottom", component: () => null, ...extra }) as ToolWindowContribution;
const list = [tw("terminal", "Terminal"), tw("plugin", "Terminal", { verbatim: true })];
expect(switcherToolWindows(list, true, "").map((x) => x.title)).toEqual(["终端", "Terminal"]);
expect(switcherToolWindows(list, true, "终端")).toEqual([{ tw: list[0], title: "终端", indices: [0, 1] }]);
expect(switcherToolWindows(list, true, "term").map((x) => [x.title, x.indices.length])).toEqual([
["终端", 0],
["Terminal", 4],
]);
} finally {
useI18n.setState({ texts: previous });
}
});
});
describe("navigation history snapshot", () => {
+3 -3
Переглянути файл
@@ -363,7 +363,7 @@ function RecentFilesDialog() {
focusable={false}
rowHeight={24}
aria-label="Tool windows"
renderItem={(t) => <ToolRow tw={t.tw} indices={t.indices} />}
renderItem={(t) => <ToolRow tw={t.tw} title={t.title} indices={t.indices} />}
/>
{!switcher && (
<button
@@ -416,12 +416,12 @@ function RecentFilesDialog() {
);
}
function ToolRow({ tw, indices }: { tw: ToolWindowContribution; indices: number[] }) {
function ToolRow({ tw, title, indices }: { tw: ToolWindowContribution; title: string; indices: number[] }) {
const shortcut = shortcutLabel(`toolwindow.${tw.id}`);
return (
<>
<Icon name={tw.icon} size={16} className={styles.icon} />
<HighlightedText className={styles.name} text={tw.title} indices={indices} tone="strong" />
<HighlightedText className={styles.name} text={title} indices={indices} tone="strong" />
{shortcut && <span className={styles.shortcut}>{shortcut}</span>}
</>
);
+11 -7
Переглянути файл
@@ -6,6 +6,7 @@ import { basename, relDir, symbolDisplayName } from "../common/open";
import type { RecentLocation } from "../common/locations";
import { matchText } from "../common/rank";
import { isVirtualUri, virtualContainer } from "@/platform/virtualDocs";
import { toolWindowTitle } from "@/workbench/toolwindows/title";
export interface RecentFileItem {
path: string;
@@ -127,7 +128,7 @@ export function switcherToolWindows(
windows: Iterable<ToolWindowContribution>,
projectOpen: boolean,
query: string,
): Array<{ tw: ToolWindowContribution; indices: number[] }> {
): Array<{ tw: ToolWindowContribution; title: string; indices: number[] }> {
const list = [...windows]
.filter((tw) => projectOpen || tw.requiresProject === false)
.sort(
@@ -135,12 +136,15 @@ export function switcherToolWindows(
ANCHOR_ORDER[a.anchor] - ANCHOR_ORDER[b.anchor] ||
Number(!!a.secondary) - Number(!!b.secondary) ||
(a.order ?? 0) - (b.order ?? 0),
);
if (!query.trim()) return list.map((tw) => ({ tw, indices: [] }));
const out: Array<{ tw: ToolWindowContribution; indices: number[] }> = [];
for (const tw of list) {
const hit = matchText(tw.title, query);
if (hit) out.push({ tw, indices: hit.indices });
)
.map((tw) => ({ tw, title: toolWindowTitle(tw), indices: [] as number[] }));
if (!query.trim()) return list;
const out: Array<{ tw: ToolWindowContribution; title: string; indices: number[] }> = [];
for (const row of list) {
const hit = matchText(row.title, query);
// The English name still finds a translated window, without highlights.
if (hit) out.push({ ...row, indices: hit.indices });
else if (row.title !== row.tw.title && matchText(row.tw.title, query)) out.push(row);
}
return out;
}
+9 -13
Переглянути файл
@@ -60,14 +60,10 @@ import {
type ToolWindowViewMode,
} from "./store";
import { contentTabRegistry } from "./content";
import { toolWindowTitle } from "./title";
import styles from "./ToolWindows.module.css";
import { tx, useI18n } from "@/platform/i18n";
/** The window's title in the UI language; a plugin's stays as written. */
function titleOf(tw: ToolWindowContribution): string {
return tw.verbatim ? tw.title : tx(tw.title);
}
function byOrder(a: ToolWindowContribution, b: ToolWindowContribution) {
return (a.order ?? 100) - (b.order ?? 100) || a.title.localeCompare(b.title);
}
@@ -457,7 +453,7 @@ function StripeButton({
active && focused && styles.stripeFocused,
dragged && styles.stripeDragged,
)}
aria-label={titleOf(tw)}
aria-label={toolWindowTitle(tw)}
aria-pressed={active}
aria-keyshortcuts={shortcut}
data-stripe-button={tw.id}
@@ -470,7 +466,7 @@ function StripeButton({
showContextMenu(e, stripeButtonMenu(tw, showName));
}}
data-tooltip-stripe={side}
{...tooltipAttrs(titleOf(tw), shortcut, true)}
{...tooltipAttrs(toolWindowTitle(tw), shortcut, true)}
>
<span className={styles.stripeIcon}>
<Icon name={tw.icon} size={20} />
@@ -478,7 +474,7 @@ function StripeButton({
</span>
{showName && (
<span className={clsx(styles.stripeLabel, !/\s/.test(tw.title) && styles.stripeLabelWord)} aria-hidden="true">
{titleOf(tw)}
{toolWindowTitle(tw)}
</span>
)}
</button>
@@ -739,7 +735,7 @@ function ToolWindowActionsBar({ tw, className }: { tw: ToolWindowContribution; c
anchor={moreRef}
items={more}
placement="bottom-end"
aria-label={tx`${titleOf(tw)} options`}
aria-label={tx`${toolWindowTitle(tw)} options`}
/>
</>
);
@@ -794,7 +790,7 @@ function HeaderRow({
aria-expanded={titleOpen}
onClick={() => setTitleOpen((v) => !v)}
>
<span className={styles.title}>{titleMenu ? tx(titleMenu.label) : titleOf(tw)}</span>
<span className={styles.title}>{titleMenu ? tx(titleMenu.label) : toolWindowTitle(tw)}</span>
<Icon name="chevron-down" size={12} className={styles.titleChevron} />
</button>
<Menu
@@ -802,11 +798,11 @@ function HeaderRow({
onClose={() => setTitleOpen(false)}
anchor={titleRef}
items={titleItems}
aria-label={titleMenu ? tx`${titleOf(tw)} views` : tx`${titleOf(tw)} view options`}
aria-label={titleMenu ? tx`${toolWindowTitle(tw)} views` : tx`${toolWindowTitle(tw)} view options`}
/>
</>
) : (
<span className={clsx(styles.title, styles.titlePlain)}>{titleOf(tw)}</span>
<span className={clsx(styles.title, styles.titlePlain)}>{toolWindowTitle(tw)}</span>
)}
{children && <div className={clsx(styles.headerContent, !showTitle && styles.headerContentOnly)}>{children}</div>}
<div className={styles.headerSpacer} />
@@ -877,7 +873,7 @@ function ToolWindowView({ tw, hidden }: { tw: ToolWindowContribution; hidden: bo
className={styles.window}
data-toolwindow={tw.id}
data-focus-scope=""
aria-label={titleOf(tw)}
aria-label={toolWindowTitle(tw)}
hidden={hidden}
tabIndex={-1}
// WebKit doesn't focus a clicked button. A menu opened from this window would then hand
+7
Переглянути файл
@@ -0,0 +1,7 @@
import { tx } from "@/platform/i18n";
import type { ToolWindowContribution } from "@/workbench/contributions";
/** The window's title in the UI language; a plugin's stays as written. */
export function toolWindowTitle(tw: Pick<ToolWindowContribution, "title" | "verbatim">): string {
return tw.verbatim ? tw.title : tx(tw.title);
}