feat(editor): optional space completion confirmation for SQL Server
This commit is contained in:
24 files changed
+202
-2
No files matched your search
@@ -72,6 +72,32 @@ describe("settings search", () => {
|
||||
expect(searchSettings(entries, "line number", "en").map((entry) => entry.id)).toEqual(["editor-line-numbers"]);
|
||||
});
|
||||
|
||||
it("indexes SQL Server space confirmation when SQL Server exists or an exported setting is enabled", () => {
|
||||
const definition = SETTINGS_SEARCH_DEFINITIONS.find((entry) => entry.id === "editor-sqlserver-space-completion");
|
||||
expect(definition).toEqual(
|
||||
expect.objectContaining({
|
||||
id: "editor-sqlserver-space-completion",
|
||||
category: "editor",
|
||||
titleKey: "settings.sqlServerSpaceConfirmsCompletion",
|
||||
descriptionKey: "settings.sqlServerSpaceConfirmsCompletionDescription",
|
||||
targetId: "editor",
|
||||
visible: expect.any(Function),
|
||||
}),
|
||||
);
|
||||
|
||||
const context = { isWeb: false, visibleCategories: new Set<SettingsCategory>(["editor"]) };
|
||||
const withoutSqlServer = resolveSettingsSearchEntries(SETTINGS_SEARCH_DEFINITIONS, { ...context, hasSqlServerConnection: false, sqlServerSpaceConfirmsCompletionEnabled: false }, translate, categoryLabels);
|
||||
const importedWithoutSqlServer = resolveSettingsSearchEntries(SETTINGS_SEARCH_DEFINITIONS, { ...context, hasSqlServerConnection: false, sqlServerSpaceConfirmsCompletionEnabled: true }, translate, categoryLabels);
|
||||
const withSqlServer = resolveSettingsSearchEntries(SETTINGS_SEARCH_DEFINITIONS, { ...context, hasSqlServerConnection: true, sqlServerSpaceConfirmsCompletionEnabled: false }, translate, categoryLabels);
|
||||
|
||||
expect(withoutSqlServer.map((entry) => entry.id)).not.toContain("editor-sqlserver-space-completion");
|
||||
expect(importedWithoutSqlServer.map((entry) => entry.id)).toContain("editor-sqlserver-space-completion");
|
||||
expect(withSqlServer.map((entry) => entry.id)).toContain("editor-sqlserver-space-completion");
|
||||
expect(settingsDialogSource).toContain('const hasSqlServerConnection = computed(() => connectionStore.connections.some((connection) => effectiveDatabaseTypeForConnection(connection) === "sqlserver"));');
|
||||
expect(settingsDialogSource).toContain("const showSqlServerSpaceConfirmsCompletion = computed(");
|
||||
expect(settingsDialogSource).toContain('<div v-if="showSqlServerSpaceConfirmsCompletion" class="settings-item flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">');
|
||||
});
|
||||
|
||||
it("does not index connection or query timeout under editor settings", () => {
|
||||
expect(SETTINGS_SEARCH_DEFINITIONS.map((definition) => definition.id)).not.toContain("editor-global-connect-timeout");
|
||||
expect(SETTINGS_SEARCH_DEFINITIONS.map((definition) => definition.id)).not.toContain("editor-global-query-timeout");
|
||||
|
||||
@@ -26,6 +26,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
|
||||
"showInsertValueHints",
|
||||
"autoAliasTables",
|
||||
"insertSpaceAfterCompletion",
|
||||
"sqlServerSpaceConfirmsCompletion",
|
||||
"sortCompletionColumnsAlphabetically",
|
||||
"selectFirstCompletionOnOpen",
|
||||
"wordWrap",
|
||||
|
||||
@@ -13,6 +13,8 @@ export function resolveSettingsCategory(initialTab?: string): SettingsCategory {
|
||||
|
||||
export interface SettingsSearchContext {
|
||||
isWeb: boolean;
|
||||
hasSqlServerConnection?: boolean;
|
||||
sqlServerSpaceConfirmsCompletionEnabled?: boolean;
|
||||
visibleCategories: ReadonlySet<SettingsCategory>;
|
||||
}
|
||||
|
||||
@@ -88,6 +90,7 @@ export function createToolbarVisibilitySettingsSearchDefinitions(items: readonly
|
||||
|
||||
const desktopOnly = (context: SettingsSearchContext) => !context.isWeb;
|
||||
const webOnly = (context: SettingsSearchContext) => context.isWeb;
|
||||
const sqlServerSpaceCompletionVisible = (context: SettingsSearchContext) => context.hasSqlServerConnection === true || context.sqlServerSpaceConfirmsCompletionEnabled === true;
|
||||
|
||||
export interface ShortcutSearchDefinitionSource {
|
||||
id: string;
|
||||
@@ -129,6 +132,7 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
|
||||
{ id: "editor-vim", category: "editor", titleKey: "settings.vimMode", descriptionKey: "settings.vimModeDescription", targetId: "editor" },
|
||||
{ id: "editor-brackets", category: "editor", titleKey: "settings.autoCloseBrackets", descriptionKey: "settings.autoCloseBracketsDescription", targetId: "editor" },
|
||||
{ id: "editor-completion-spacing", category: "editor", titleKey: "settings.insertSpaceAfterCompletion", descriptionKey: "settings.insertSpaceAfterCompletionDescription", targetId: "editor" },
|
||||
{ id: "editor-sqlserver-space-completion", category: "editor", titleKey: "settings.sqlServerSpaceConfirmsCompletion", descriptionKey: "settings.sqlServerSpaceConfirmsCompletionDescription", targetId: "editor", visible: sqlServerSpaceCompletionVisible },
|
||||
{ id: "editor-completion-trigger-mode", category: "editor", titleKey: "settings.completionTriggerMode", descriptionKey: "settings.completionTriggerModeDescription", targetId: "editor" },
|
||||
{ id: "editor-auto-alias", category: "editor", titleKey: "settings.autoAliasTables", descriptionKey: "settings.autoAliasTablesDescription", targetId: "editor" },
|
||||
{ id: "editor-unsaved-close", category: "editor", titleKey: "settings.confirmUnsavedSqlClose", descriptionKey: "settings.confirmUnsavedSqlCloseDescription", targetId: "editor" },
|
||||
|
||||
@@ -83,6 +83,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
|
||||
"showInsertValueHints",
|
||||
"autoAliasTables",
|
||||
"insertSpaceAfterCompletion",
|
||||
"sqlServerSpaceConfirmsCompletion",
|
||||
"sortCompletionColumnsAlphabetically",
|
||||
"selectFirstCompletionOnOpen",
|
||||
"completionTriggerMode",
|
||||
|
||||
Reference in new issue
Block a user