fix(settings): align Smart Keys backspace and paste controls (#4823)

Settings > Editor > General > Smart Keys places the Backspace and paste formatting controls directly below the Enter options; the two controls share a label column and the paste escaping option sits below the formatting control.
This commit is contained in:
l0ng-ai
2026-11-20 23:54:10 +08:00
committed by GitHub
parent a4574fdc92
commit f2c0fcdc96
4 changed files with 96 additions and 28 deletions
+67
View File
@@ -0,0 +1,67 @@
import type { Page } from "@playwright/test";
import { expect, test } from "./fixtures";
async function openSmartKeys(page: Page) {
await page.keyboard.press("Meta+,");
const dialog = page.getByRole("dialog", { name: "Settings", exact: true });
await dialog.getByRole("textbox", { name: "Search settings" }).fill("Smart Keys");
await dialog.getByRole("treeitem", { name: "Smart Keys", exact: true }).click();
return dialog;
}
test("backspace and paste controls align below Enter options in Smart Keys", async ({ workbench: page }) => {
const dialog = await openSmartKeys(page);
const enter = dialog.getByRole("region", { name: "Enter", exact: true });
const unindent = dialog.getByRole("button", { name: /^Unindent(?: on Backspace)?$/ });
const paste = dialog.getByRole("button", { name: "Reformat on paste", exact: true });
const escape = dialog.getByRole("checkbox", { name: "Escape text on paste in string literals", exact: true });
for (const width of [1120, 520]) {
await page.setViewportSize({ width, height: 760 });
await expect(unindent).toBeInViewport({ ratio: 0.98 });
await expect(paste).toBeInViewport({ ratio: 0.98 });
const enterBox = (await enter.boundingBox())!;
const unindentBox = (await unindent.boundingBox())!;
const pasteBox = (await paste.boundingBox())!;
expect(unindentBox.y).toBeGreaterThan(enterBox.y + enterBox.height);
expect(pasteBox.y).toBeGreaterThanOrEqual(unindentBox.y + unindentBox.height);
expect(Math.abs(pasteBox.x - unindentBox.x)).toBeLessThan(1);
expect((await escape.boundingBox())!.y).toBeGreaterThanOrEqual(pasteBox.y + pasteBox.height);
}
await paste.click();
await expect(page.getByRole("option", { name: "Indent Each Line", exact: true })).toBeInViewport();
});
test("Smart Keys keeps backspace and paste preferences independent across Apply and Cancel", async ({
workbench: page,
}) => {
const setOption = async (label: string, option: string) => {
await page
.getByRole("dialog", { name: "Settings", exact: true })
.getByRole("button", { name: label, exact: true })
.click();
await page.getByRole("option", { name: option, exact: true }).click();
};
const dialog = await openSmartKeys(page);
await setOption("Unindent on Backspace", "To nearest indent position");
await setOption("Reformat on paste", "Indent Block");
await dialog.getByRole("button", { name: "Apply", exact: true }).click();
await expect(dialog.getByRole("button", { name: "Apply", exact: true })).toBeDisabled();
await dialog.getByRole("button", { name: "Cancel", exact: true }).click();
const reopened = await openSmartKeys(page);
await expect(reopened.getByRole("button", { name: "Unindent on Backspace", exact: true })).toHaveText(
"To nearest indent position",
);
await expect(reopened.getByRole("button", { name: "Reformat on paste", exact: true })).toHaveText("Indent Block");
await setOption("Reformat on paste", "None");
await reopened.getByRole("button", { name: "Cancel", exact: true }).click();
const final = await openSmartKeys(page);
await expect(final.getByRole("button", { name: "Unindent on Backspace", exact: true })).toHaveText(
"To nearest indent position",
);
await expect(final.getByRole("button", { name: "Reformat on paste", exact: true })).toHaveText("Indent Block");
});
+27 -28
View File
@@ -736,12 +736,6 @@ const SMART_KEYS = editorPage({
{
items: [
{ t: "check", key: `${P}.smartKeys.smartHome`, label: "Home moves caret to first non-whitespace character" },
{
t: "check",
key: `${P}.smartKeys.camelHumps`,
label: 'Use "CamelHumps" words',
hint: "⌥← / ⌥→ and ⌥⌫ stop at humps of camelCase names.",
},
{
t: "check",
key: `${P}.smartKeys.pairBrackets`,
@@ -749,9 +743,36 @@ const SMART_KEYS = editorPage({
hint: "Also pairs <> for generics where the syntax says a type starts.",
},
{ t: "check", key: `${P}.smartKeys.pairQuotes`, label: "Insert pair quote" },
{
t: "check",
key: `${P}.smartKeys.camelHumps`,
label: 'Use "CamelHumps" words',
hint: "⌥← / ⌥→ and ⌥⌫ stop at humps of camelCase names.",
},
{ t: "check", key: `${P}.smartKeys.surroundSelection`, label: "Surround selection on typing quote or brace" },
{ t: "check", key: `${P}.smartKeys.tabOutOfPair`, label: "Jump outside closing bracket/quote with Tab" },
{ t: "check", key: `${P}.smartKeys.simultaneousTagEditing`, label: "Simultaneous <tag></tag> editing" },
],
},
{
title: "Enter",
items: [
{ t: "check", key: `${P}.smartKeys.smartIndent`, label: "Smart indent" },
{ t: "check", key: `${P}.smartKeys.insertDocStub`, label: "Insert documentation comment stub" },
],
},
{
items: [
{
t: "select",
key: `${P}.smartKeys.backspaceUnindent`,
label: "Unindent on Backspace",
options: [
{ value: "autoindent", label: "To proper indent position" },
{ value: "nearest", label: "To nearest indent position" },
{ value: "none", label: "Disabled" },
],
},
{
t: "select",
key: `${P}.smartKeys.reformatOnPaste`,
@@ -769,28 +790,6 @@ const SMART_KEYS = editorPage({
},
],
},
{
title: "Enter",
items: [
{ t: "check", key: `${P}.smartKeys.smartIndent`, label: "Smart indent" },
{ t: "check", key: `${P}.smartKeys.insertDocStub`, label: "Insert documentation comment stub" },
],
},
{
title: "Backspace",
items: [
{
t: "select",
key: `${P}.smartKeys.backspaceUnindent`,
label: "Unindent",
options: [
{ value: "autoindent", label: "To proper indent position" },
{ value: "nearest", label: "To nearest indent position" },
{ value: "none", label: "Disabled" },
],
},
],
},
],
});
+1
View File
@@ -514,6 +514,7 @@
"Inlay hint preview": "Inlay hint preview",
"Inlay hint categories": "Inlay hint categories",
"Parameter": "Parameter",
"Unindent on Backspace": "Unindent on Backspace",
"Global variable": "Global variable",
"Package reference": "Package reference",
"Constant": "Constant",
+1
View File
@@ -457,6 +457,7 @@
"Inlay hint preview": "嵌入提示预览",
"Inlay hint categories": "嵌入提示类别",
"Parameter": "参数",
"Unindent on Backspace": "按退格键取消缩进",
"Package reference": "包引用",
"Instance field": "实例字段",
"Static symbol": "静态符号",