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

...
Автор SHA1 Повідомлення Дата
l0ng-ai 7dd6a1e779 fix(keymap): make shortcut recording and conflicts easier to read 2026-11-22 21:29:05 +08:00
12 змінених файлів з 164 додано та 67 видалено

No files matched your search

+44
Переглянути файл
@@ -0,0 +1,44 @@
import { expect, test } from "./fixtures";
test("shortcut assignment fits the first stroke and conflict names in a narrow window", async ({ workbench: page }) => {
await page.setViewportSize({ width: 336, height: 540 });
await page.keyboard.press("Meta+,");
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
await settings.getByRole("treeitem", { name: "Keymap", exact: true }).click();
await settings.getByRole("textbox", { name: "Search actions" }).fill("Find Action");
const action = settings.getByRole("treeitem", { name: /Find Action/ });
await action.click();
await settings.getByRole("button", { name: "Add Keyboard Shortcut", exact: true }).click();
const dialog = page.getByRole("dialog", { name: "Keyboard Shortcut: Find Action…", exact: true });
const first = dialog.getByRole("textbox", { name: "First stroke" });
const body = dialog.locator("[data-dialog-body]");
const titleBar = dialog.locator("[data-dialog-titlebar]");
await expect(first).toBeFocused();
await expect(titleBar).toHaveText("Keyboard Shortcut");
await expect(body.getByText("Find Action…", { exact: true })).toBeVisible();
const firstBounds = (await first.boundingBox())!;
const bodyBounds = (await body.boundingBox())!;
expect(firstBounds.width).toBeGreaterThan(bodyBounds.width - 32);
const conflicts = dialog.getByRole("list", { name: "Conflicts:" });
await expect(conflicts).toHaveCount(0);
await first.press("Meta+Alt+L");
await expect(conflicts).toBeVisible();
await expect(conflicts.getByRole("listitem").filter({ hasText: "Reformat Code" }).first()).toBeVisible();
expect(await conflicts.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
expect(
await conflicts
.getByRole("listitem")
.evaluateAll((rows) => rows.every((row) => row.scrollHeight <= row.clientHeight)),
).toBe(true);
expect(await body.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
const ok = dialog.getByRole("button", { name: "OK", exact: true });
await ok.click();
const confirmation = page.getByRole("dialog", { name: "Warning", exact: true });
await expect(confirmation.getByRole("list").getByText("Reformat Code", { exact: true })).toHaveCount(2);
await confirmation.getByRole("button", { name: "Leave", exact: true }).click();
await expect(dialog).toBeHidden();
await expect(action.locator("kbd").filter({ hasText: "⌥⌘L" })).toHaveCount(1);
});
+56 -24
Переглянути файл
@@ -30,9 +30,6 @@
.presetSelect {
flex: 1;
}
.spacer {
flex: 1;
}
.modifiedNote {
color: var(--fg-subtle);
font-size: var(--fs-small);
@@ -195,53 +192,88 @@
.recordLabel {
color: var(--fg);
}
.shortcutBody {
display: flex;
flex-direction: column;
gap: var(--space-2);
padding: var(--space-2) var(--space-3) 0;
font-size: var(--fs-ui);
overflow-wrap: anywhere;
}
.actionSummary {
display: grid;
gap: var(--space-0-5);
}
.actionName {
color: var(--fg-strong);
font-weight: 600;
}
.shortcutField {
flex: 0 0 auto;
background: var(--bg-field);
}
.shortcutField > span {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.secondStroke {
display: flex;
align-items: center;
gap: var(--space-2);
}
.secondStroke > label {
max-width: 55%;
}
.secondStroke .shortcutField {
flex: 1;
}
.recordHint {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.conflicts {
min-height: 72px;
padding: 6px 8px;
border-radius: var(--radius-small);
box-shadow: inset 0 0 0 1px var(--border);
}
.noConflicts {
color: var(--fg-subtle);
.shortcutStatus {
display: grid;
gap: var(--space-1);
}
.conflictTitle {
display: flex;
align-items: center;
gap: var(--space-1-5);
color: var(--fg-emphasis);
font-weight: 600;
}
.conflictIcon {
flex: none;
color: var(--warning);
--icon-color: currentColor;
}
.conflictList {
list-style: none;
margin: 6px 0 0;
padding: 0 0 0 20px;
max-height: 120px;
overflow: auto;
margin: 0;
padding: 0;
max-height: 132px;
overflow-y: auto;
}
.conflictList li {
display: flex;
min-width: 0;
align-items: center;
display: grid;
grid-template-columns: minmax(0, 1fr) fit-content(42%);
align-items: start;
gap: var(--space-2);
height: var(--h-row);
padding-block: var(--space-1);
}
.conflictAction {
color: var(--fg);
overflow-wrap: anywhere;
}
.conflictCategory {
.actionPath {
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.conflictsLabel {
color: var(--fg);
padding-top: 4px;
.conflictBinding {
text-align: end;
white-space: normal;
overflow-wrap: anywhere;
}
.nameError {
color: var(--danger);
+46 -35
Переглянути файл
@@ -20,7 +20,7 @@ import { findConflicts, resolveBindings, type Conflict, type KeymapDraft } from
import { groupPath } from "./groups";
import { StrokeRecorder } from "./StrokeRecorder";
import styles from "./Keymap.module.css";
import { tx } from "@/platform/i18n";
import { useTx } from "@/platform/i18n";
import { usePlatform } from "@/platform/platformInfo";
export interface RecordShortcutDialogProps {
@@ -39,6 +39,8 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
const [second, setSecond] = useState("");
const [useSecond, setUseSecond] = useState(false);
const os = usePlatform((s) => s.os);
const tx = useTx();
const actionName = tx(action.title);
const rectangularSelection = action.id === "editor.createRectangularSelectionOnMouseDrag";
const allowsSecond = !isPageSwipe(first) && !parseDoubleModifier(first);
@@ -76,14 +78,23 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
<Dialog
open
onClose={onCancel}
title={mouse ? tx`Mouse Shortcut: ${action.title}` : tx`Keyboard Shortcut: ${action.title}`}
width={440}
title={mouse ? "Mouse Shortcut" : "Keyboard Shortcut"}
aria-label={mouse ? tx`Mouse Shortcut: ${actionName}` : tx`Keyboard Shortcut: ${actionName}`}
width={352}
buttons={[
{ label: "OK", role: "default", disabled: !binding || already, onClick: () => void ok() },
{ label: "Cancel", role: "cancel" },
]}
>
<div className={styles.recordBody}>
<div className={styles.shortcutBody}>
<div className={styles.actionSummary}>
<div className={styles.actionName}>{actionName}</div>
<div className={styles.actionPath}>
{groupPath(action)
.map((part) => tx(part))
.join(" › ")}
</div>
</div>
{mouse ? (
<MouseRecorder value={first} onChange={setFirst} sideButtons={!rectangularSelection} />
) : (
@@ -102,31 +113,23 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
<T>On Linux, middle-button rectangular selection conflicts with primary selection paste.</T>
</div>
)}
<div className={styles.conflictsLabel}>
<T>Conflicts:</T>
</div>
<div className={styles.conflicts} aria-live="polite">
<div className={styles.shortcutStatus} aria-live="polite">
{already && (
<span className={styles.noConflicts}>
<span className={styles.recordHint}>
<T>The action already has this shortcut</T>
</span>
)}
{!already && binding && conflicts.length === 0 && (
<span className={styles.noConflicts}>
<span className={styles.recordHint}>
<T>No conflicts</T>
</span>
)}
{!binding && (
<span className={styles.noConflicts}>
<T>Press a shortcut</T>
</span>
)}
{conflicts.length > 0 && (
<>
<div className={styles.conflictTitle}>
<Icon name="warning" size={14} className={styles.conflictIcon} />
<span>
<Kbd binding={binding} /> <T>is already assigned to:</T>
<Kbd binding={binding} className={styles.conflictBinding} /> <T>is already assigned to:</T>
</span>
</div>
<ConflictList conflicts={conflicts} />
@@ -139,21 +142,26 @@ export function RecordShortcutDialog({ action, actions, draft, onCancel, onSubmi
}
function ConflictList({ conflicts }: { conflicts: readonly Conflict[] }) {
const tx = useTx();
return (
<ul className={styles.conflictList}>
<ul className={styles.conflictList} aria-label={tx("Conflicts:")}>
{conflicts.map((c) => (
<li key={`${c.actionId}|${c.binding}`}>
<span className={styles.conflictAction}>{c.title}</span>
<span className={styles.conflictCategory}>
({groupPath({ id: c.actionId, category: c.category }).join(" | ")})
</span>
<span className={styles.spacer} />
{c.kind === "prefix" && (
<span className={styles.conflictCategory}>
<T>chord prefix</T>
<div className={styles.conflictAction}>
<div>{tx(c.title)}</div>
<span className={styles.actionPath}>
{groupPath({ id: c.actionId, category: c.category })
.map((part) => tx(part))
.join(" › ")}
{c.kind === "prefix" && (
<>
{" "}
· <T>chord prefix</T>
</>
)}
</span>
)}
<Kbd binding={c.binding} />
</div>
<Kbd binding={c.binding} className={styles.conflictBinding} />
</li>
))}
</ul>
@@ -171,23 +179,26 @@ interface KeyStrokesProps {
}
function KeyStrokes({ first, second, useSecond, allowsSecond, setFirst, setSecond, setUseSecond }: KeyStrokesProps) {
const tx = useTx();
return (
<>
<div className={styles.recordRow}>
<span className={styles.recordLabel}>
<T>First stroke:</T>
</span>
<StrokeRecorder autoFocus value={first} onChange={setFirst} aria-label="First stroke" />
</div>
<div className={styles.recordRow}>
<StrokeRecorder
autoFocus
className={styles.shortcutField}
value={first}
onChange={setFirst}
aria-label={tx("First stroke")}
/>
<div className={styles.secondStroke}>
<Checkbox checked={useSecond} onChange={setUseSecond} disabled={!allowsSecond} label="Second stroke:" />
<StrokeRecorder
className={styles.shortcutField}
value={second}
onChange={setSecond}
disabled={!useSecond}
allowDoubleModifier={false}
placeholder={useSecond ? "Press a shortcut" : ""}
aria-label="Second stroke"
aria-label={tx("Second stroke")}
/>
</div>
<div className={styles.recordHint}>
+2
Переглянути файл
@@ -2093,6 +2093,8 @@
"e.g. /api/": "e.g. /api/",
"Part of a request URL": "Part of a request URL",
"Mouse": "Mouse",
"Keyboard Shortcut": "Keyboard Shortcut",
"Mouse Shortcut": "Mouse Shortcut",
"Keyboard": "Keyboard",
"Form": "Form",
"Page": "Page",
+2 -1
Переглянути файл
@@ -894,7 +894,6 @@
"Find…": "Buscar…",
"First letter only": "Solo la primera letra",
"First stroke": "Primera combinación de teclas",
"First stroke:": "Primera combinación de teclas:",
"Fix the highlighted fields": "Corrige los campos resaltados",
"Flame Graph": "Gráfico de llamas",
"Flame graph": "Gráfico de llamas",
@@ -4100,6 +4099,7 @@
"based on {parent}": "basado en {parent}",
"Delete keymap '{name}'?": "¿Eliminar el mapa de teclado '{name}'?",
"Remove {shortcut}": "Quitar {shortcut}",
"Keyboard Shortcut": "Atajo de teclado",
"Keyboard Shortcut: {action}": "Atajo de teclado: {action}",
"Remove content root {path}": "Quitar raíz de contenido {path}",
"Unmark {folder}": "Desmarcar {folder}",
@@ -4844,6 +4844,7 @@
"Add Mouse Shortcut": "Agregar atajo de ratón",
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Haga clic aquí manteniendo presionado Ctrl, Alt o Command, o use el botón central o un botón lateral del ratón",
"Mouse shortcut": "Atajo de ratón",
"Mouse Shortcut": "Atajo de ratón",
"Mouse Shortcut: {action}": "Atajo de ratón: {action}",
"Accept Left Side": "Aceptar lado izquierdo",
"Accept Right Side": "Aceptar lado derecho",
+2 -1
Переглянути файл
@@ -831,7 +831,6 @@
"Find…": "Rechercher…",
"First letter only": "Première lettre uniquement",
"First stroke": "Première touche",
"First stroke:": "Première touche :",
"Fix the highlighted fields": "Corrigez les champs mis en évidence",
"Flame Graph": "Flame graph",
"Flame graph": "Flame graph",
@@ -3964,6 +3963,7 @@
"based on {parent}": "basé sur {parent}",
"Delete keymap '{name}'?": "Supprimer les raccourcis clavier '{name}' ?",
"Remove {shortcut}": "Retirer {shortcut}",
"Keyboard Shortcut": "Raccourci clavier",
"Keyboard Shortcut: {action}": "Raccourci clavier : {action}",
"Remove content root {path}": "Retirer la racine de contenu {path}",
"Unmark {folder}": "Démarquer {folder}",
@@ -4699,6 +4699,7 @@
"Add Mouse Shortcut": "Ajouter un raccourci souris",
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Cliquez ici en maintenant Ctrl, Alt ou Commande, ou utilisez le bouton central ou un bouton latéral de la souris",
"Mouse shortcut": "Raccourci souris",
"Mouse Shortcut": "Raccourci souris",
"Mouse Shortcut: {action}": "Raccourci souris : {action}",
"Accept Left Side": "Accepter le côté gauche",
"Accept Right Side": "Accepter le côté droit",
+2 -1
Переглянути файл
@@ -930,7 +930,6 @@
"Find…": "찾기…",
"First letter only": "첫 글자만",
"First stroke": "첫 번째 키 입력",
"First stroke:": "첫 번째 키 입력:",
"Fix the highlighted fields": "강조 표시된 필드를 수정하세요",
"Flame Graph": "플레임 그래프",
"Flame graph": "플레임 그래프",
@@ -4161,6 +4160,7 @@
"based on {parent}": "{parent} 기반",
"Delete keymap '{name}'?": "키맵 '{name}'을(를) 삭제하시겠습니까?",
"Remove {shortcut}": "{shortcut} 제거",
"Keyboard Shortcut": "키보드 단축키",
"Keyboard Shortcut: {action}": "키보드 단축키: {action}",
"Remove content root {path}": "콘텐츠 루트 {path} 제거",
"Unmark {folder}": "{folder} 표시 해제",
@@ -4916,6 +4916,7 @@
"Add Mouse Shortcut": "마우스 단축키 추가",
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Ctrl, Alt 또는 Command를 누른 채 여기를 클릭하거나 마우스 가운데 버튼 또는 측면 버튼을 사용하세요",
"Mouse shortcut": "마우스 단축키",
"Mouse Shortcut": "마우스 단축키",
"Mouse Shortcut: {action}": "마우스 단축키: {action}",
"Accept Left Side": "왼쪽 수락",
"Accept Right Side": "오른쪽 수락",
+2 -1
Переглянути файл
@@ -886,7 +886,6 @@
"Find…": "Znajdź…",
"First letter only": "Tylko pierwsza litera",
"First stroke": "Naciśnięcie pierwsze",
"First stroke:": "Naciśnięcie pierwsze:",
"Fix the highlighted fields": "Popraw podświetlone pola",
"Flame Graph": "Wykres płomieniowy (Flame Graph)",
"Flame graph": "Wykres płomieniowy",
@@ -4056,6 +4055,7 @@
"based on {parent}": "na podstawie {parent}",
"Delete keymap '{name}'?": "Usunąć mapę klawiszy '{name}'?",
"Remove {shortcut}": "Usuń {shortcut}",
"Keyboard Shortcut": "Skrót klawiszowy",
"Keyboard Shortcut: {action}": "Skrót klawiszowy: {action}",
"Remove content root {path}": "Usuń katalog główny zawartości {path}",
"Unmark {folder}": "Odznacz {folder}",
@@ -4796,6 +4796,7 @@
"Add Mouse Shortcut": "Dodaj skrót myszy",
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Kliknij tutaj przytrzymując Ctrl, Alt lub Command albo użyj środkowego lub bocznego przycisku myszy",
"Mouse shortcut": "Skrót myszy",
"Mouse Shortcut": "Skrót myszy",
"Mouse Shortcut: {action}": "Skrót myszy: {action}",
"Accept Left Side": "Zaakceptuj lewą stronę",
"Accept Right Side": "Zaakceptuj prawą stronę",
+2 -1
Переглянути файл
@@ -886,7 +886,6 @@
"Find…": "Localizar…",
"First letter only": "Apenas primeira letra",
"First stroke": "Primeiro toque",
"First stroke:": "Primeiro toque:",
"Fix the highlighted fields": "Corrija os campos destacados",
"Flame Graph": "Flame Graph",
"Flame graph": "Flame graph",
@@ -4066,6 +4065,7 @@
"based on {parent}": "com base em {parent}",
"Delete keymap '{name}'?": "Excluir o mapa de teclas '{name}'?",
"Remove {shortcut}": "Remover {shortcut}",
"Keyboard Shortcut": "Atalho do teclado",
"Keyboard Shortcut: {action}": "Atalho do teclado: {action}",
"Remove content root {path}": "Remover raiz de conteúdo {path}",
"Unmark {folder}": "Desmarcar {folder}",
@@ -4810,6 +4810,7 @@
"Add Mouse Shortcut": "Adicionar atalho de mouse",
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "Clique aqui mantendo Ctrl, Alt ou Command pressionado, ou use o botão do meio ou um botão lateral do mouse",
"Mouse shortcut": "Atalho de mouse",
"Mouse Shortcut": "Atalho de mouse",
"Mouse Shortcut: {action}": "Atalho de mouse: {action}",
"Accept Left Side": "Aceitar lado esquerdo",
"Accept Right Side": "Aceitar lado direito",
+2 -1
Переглянути файл
@@ -3682,7 +3682,6 @@
"Find…": "Bul…",
"First letter only": "Yalnızca ilk harf",
"First stroke": "İlk tuş birleşimi",
"First stroke:": "İlk tuş birleşimi:",
"Fix the highlighted fields": "Vurgulanan alanları düzeltin",
"Flame Graph": "Alev Grafiği",
"Flame graph": "Alev grafiği",
@@ -6790,6 +6789,7 @@
"based on {parent}": "{parent} temel alınarak",
"Delete keymap '{name}'?": "'{name}' tuş eşlemi silinsin mi?",
"Remove {shortcut}": "{shortcut} kaldır",
"Keyboard Shortcut": "Klavye Kısayolu",
"Keyboard Shortcut: {action}": "Klavye Kısayolu: {action}",
"Remove content root {path}": "{path} içerik kökünü kaldır",
"Unmark {folder}": "{folder} işaretini kaldır",
@@ -7522,6 +7522,7 @@
"Sort by Modification Time": "Değiştirilme Zamanına Göre Sırala",
"Add Mouse Shortcut": "Fare Kısayolu Ekle",
"Mouse shortcut": "Fare kısayolu",
"Mouse Shortcut": "Fare Kısayolu",
"Mouse Shortcut: {action}": "Fare Kısayolu: {action}",
"Accept Left Side": "Sol Tarafı Kabul Et",
"Accept Right Side": "Sağ Tarafı Kabul Et",
+2 -1
Переглянути файл
@@ -1554,7 +1554,6 @@
"Find…": "查詢…",
"First letter only": "僅首字母",
"First stroke": "第一次擊鍵",
"First stroke:": "第一次擊鍵:",
"Fix the highlighted fields": "請修復醒目提示的欄位",
"Flame Graph": "火焰圖",
"Flame graph": "火焰圖",
@@ -5044,6 +5043,7 @@
"based on {parent}": "基於 {parent}",
"Delete keymap '{name}'?": "是否刪除按鍵對映 '{name}'?",
"Remove {shortcut}": "移除 {shortcut}",
"Keyboard Shortcut": "鍵盤快速鍵",
"Keyboard Shortcut: {action}": "鍵盤快速鍵:{action}",
"Remove content root {path}": "移除內容根 {path}",
"Unmark {folder}": "取消標記 {folder}",
@@ -5831,6 +5831,7 @@
"Click here with Ctrl, Alt or Command held, or use a middle or side mouse button": "按住 Ctrl、Alt 或 Command 在此點選,或使用滑鼠中鍵或側鍵",
"Click here with Ctrl, Alt or Command held, or use the middle mouse button": "按住 Ctrl、Alt 或 Command 在此點選,或使用滑鼠中鍵",
"Mouse shortcut": "滑鼠快速鍵",
"Mouse Shortcut": "滑鼠快速鍵",
"Mouse Shortcut: {action}": "滑鼠快速鍵:{action}",
"Accept Left Side": "接受左側",
"Accept Right Side": "接受右側",
+2 -1
Переглянути файл
@@ -1620,7 +1620,6 @@
"Find…": "查找…",
"First letter only": "仅首字母",
"First stroke": "第一次击键",
"First stroke:": "第一次击键:",
"Fix the highlighted fields": "请修复高亮显示的字段",
"Flame Graph": "火焰图",
"Flame graph": "火焰图",
@@ -5132,6 +5131,8 @@
"based on {parent}": "基于 {parent}",
"Delete keymap '{name}'?": "是否删除按键映射 '{name}'?",
"Remove {shortcut}": "移除 {shortcut}",
"Keyboard Shortcut": "键盘快捷键",
"Mouse Shortcut": "鼠标快捷键",
"Keyboard Shortcut: {action}": "键盘快捷键:{action}",
"Remove content root {path}": "移除内容根 {path}",
"Unmark {folder}": "取消标记 {folder}",