feat(editor): support customizing snippet trigger key

This commit is contained in:
lxk955 authored and GitHub committed 2026-10-04 09:57:49 +08:00
1 parent b10ecd096c
commit 69687c1a84
25 files changed
+242 -10

No files matched your search

@@ -99,6 +99,12 @@ describe("EDITOR_SETTINGS_DRAFT_KEYS", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("openDataTabsNextToActive");
});
it("includes snippet trigger key setting in draft keys and draft conversion", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("snippetTriggerKey");
const draft = editorSettingsDraftFromSettings(makeSettings({ snippetTriggerKey: "space" }));
expect(draft.snippetTriggerKey).toBe("space");
});
it("includes data grid type colors", () => {
expect(EDITOR_SETTINGS_DRAFT_KEYS).toContain("colorizeDataGridCellTypes");
});
@@ -273,12 +273,14 @@ describe("settingsTransfer", () => {
theme: DEFAULT_EDITOR_SETTINGS.theme,
pageSize: 200,
snippets: [{ id: "s1", label: "L", prefix: "p", body: "SELECT 1", enabled: true }],
snippetTriggerKey: "space",
} as EditorSettings;
const result = parseSettingsTransferFile(serializeSettingsTransfer(settings));
expect(result.ok).toBe(true);
if (!result.ok) return;
expect(result.value.editorSettings.pageSize).toBe(200);
expect(result.value.editorSettings.snippets).toEqual(settings.snippets);
expect(result.value.editorSettings.snippetTriggerKey).toBe("space");
});
it("round-trips table default sorting settings", () => {
@@ -30,6 +30,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"tableCompletionSchemaQualification",
"insertSpaceAfterCompletion",
"sqlServerSpaceConfirmsCompletion",
"snippetTriggerKey",
"sortCompletionColumnsAlphabetically",
"selectFirstCompletionOnOpen",
"wordWrap",
@@ -177,6 +178,7 @@ function normalizedDraftValue(key: EditorSettingsDraftKey, value: unknown): unkn
if (key === "redisKeyTemplates") return normalizeRedisKeyTemplates(value);
if (key === "csvNullMode") return normalizeCsvNullMode(value);
if (key === "backgroundImage") return normalizeBackgroundImageSettings(value);
if (key === "snippetTriggerKey") return value === "space" || value === "both" ? value : "tab";
return value;
}
@@ -272,6 +272,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
{ id: "shortcuts", category: "shortcuts", titleKey: "settings.shortcutsTab", targetId: "shortcuts" },
{ id: "sql-shortcuts", category: "shortcuts", titleKey: "settings.sqlShortcutsTitle", descriptionKey: "settings.sqlShortcutsDescription", targetId: "sql-shortcuts" },
{ id: "snippets", category: "snippets", titleKey: "settings.snippetsTab", descriptionKey: "settings.snippetsDescription", targetId: "snippets" },
{ id: "snippet-trigger-key", category: "snippets", titleKey: "settings.snippetTriggerKey", descriptionKey: "settings.snippetTriggerKeyDescription", targetId: "snippet-trigger-key" },
{ id: "sync-webdav", category: "sync", titleKey: "settings.syncWebDavTitle", descriptionKey: "settings.syncWebDavDescription", targetId: "sync-webdav", route: { syncMethodTab: "webdav" } },
{ id: "sync-webdav-endpoint", category: "sync", titleKey: "settings.syncEndpoint", targetId: "sync-webdav", route: { syncMethodTab: "webdav" } },
{ id: "sync-webdav-username", category: "sync", titleKey: "settings.syncUsername", targetId: "sync-webdav", route: { syncMethodTab: "webdav" } },
@@ -195,7 +195,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
"globalDateTimeImportFormat",
],
shortcuts: ["shortcuts", "sqlShortcuts"],
snippets: ["snippets"],
snippets: ["snippets", "snippetTriggerKey"],
other: ["updateDownloadSource", "updateNotificationsEnabled", "autoDownloadUpdates", "autoUpdateApp", "autoUpdateDrivers", "autoUpdateJdbc", "autoUpdateMcp", "autoUpdatePlugins"],
};