feat(editor): allow hiding query line numbers
This commit is contained in:
1 parent
eaad88cc80
commit
4a478acf07
18 files changed
+205
-7
No files matched your search
@@ -131,6 +131,12 @@ describe("normalizeEditorSettings", () => {
|
||||
expect(normalizeEditorSettings({ sidebarConnectionSortMode: "invalid" as any }).sidebarConnectionSortMode).toBe("manual");
|
||||
});
|
||||
|
||||
it("shows line numbers by default and preserves an explicit opt-out", () => {
|
||||
expect(normalizeEditorSettings({}).showLineNumbers).toBe(true);
|
||||
expect(normalizeEditorSettings({ showLineNumbers: false }).showLineNumbers).toBe(false);
|
||||
expect(normalizeEditorSettings({ showLineNumbers: "false" } as any).showLineNumbers).toBe(true);
|
||||
});
|
||||
|
||||
it("shows the current statement frame by default", () => {
|
||||
expect(normalizeEditorSettings({}).showCurrentStatementFrame).toBe(true);
|
||||
});
|
||||
@@ -726,6 +732,29 @@ describe("settingsStore persisted settings initialization", () => {
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ openDataTabsNextToActive: false }));
|
||||
});
|
||||
|
||||
it("loads, persists, and reloads hidden query editor line numbers", async () => {
|
||||
let persistedSettings: Record<string, unknown> = { showLineNumbers: true };
|
||||
const loadEditorSettings = vi.fn(async () => JSON.parse(JSON.stringify(persistedSettings)));
|
||||
const saveEditorSettings = vi.fn(async (settings: Record<string, unknown>) => {
|
||||
persistedSettings = JSON.parse(JSON.stringify(settings));
|
||||
});
|
||||
vi.doMock("@/lib/backend/api", () => ({ loadEditorSettings, saveEditorSettings }));
|
||||
|
||||
const { useSettingsStore } = await import("@/stores/settingsStore");
|
||||
const store = useSettingsStore();
|
||||
await store.initEditorSettings();
|
||||
await store.updateEditorSettingsAndPersist({ showLineNumbers: false });
|
||||
|
||||
expect(store.editorSettings.showLineNumbers).toBe(false);
|
||||
expect(saveEditorSettings).toHaveBeenLastCalledWith(expect.objectContaining({ showLineNumbers: false }));
|
||||
|
||||
setActivePinia(createPinia());
|
||||
const restartedStore = useSettingsStore();
|
||||
await restartedStore.initEditorSettings();
|
||||
|
||||
expect(restartedStore.editorSettings.showLineNumbers).toBe(false);
|
||||
});
|
||||
|
||||
it("shares concurrent initialization and applies startup changes after saved settings load", async () => {
|
||||
let resolveLoad!: (value: unknown) => void;
|
||||
const loadEditorSettings = vi.fn(
|
||||
|
||||
@@ -525,6 +525,7 @@ export interface EditorSettings {
|
||||
timeoutInheritanceMigrationVersion: number;
|
||||
showExecutionTargetPicker: boolean;
|
||||
showStatementRunButtons: boolean;
|
||||
showLineNumbers: boolean;
|
||||
showCurrentStatementFrame: boolean;
|
||||
showInsertValueHints: boolean;
|
||||
autoAliasTables: boolean;
|
||||
@@ -733,6 +734,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
|
||||
timeoutInheritanceMigrationVersion: 2,
|
||||
showExecutionTargetPicker: false,
|
||||
showStatementRunButtons: true,
|
||||
showLineNumbers: true,
|
||||
showCurrentStatementFrame: true,
|
||||
showInsertValueHints: true,
|
||||
autoAliasTables: true,
|
||||
@@ -1105,6 +1107,7 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
|
||||
: 0,
|
||||
showExecutionTargetPicker: settings.showExecutionTargetPicker ?? DEFAULT_EDITOR_SETTINGS.showExecutionTargetPicker,
|
||||
showStatementRunButtons: typeof settings.showStatementRunButtons === "boolean" ? settings.showStatementRunButtons : DEFAULT_EDITOR_SETTINGS.showStatementRunButtons,
|
||||
showLineNumbers: typeof settings.showLineNumbers === "boolean" ? settings.showLineNumbers : DEFAULT_EDITOR_SETTINGS.showLineNumbers,
|
||||
showCurrentStatementFrame: typeof settings.showCurrentStatementFrame === "boolean" ? settings.showCurrentStatementFrame : DEFAULT_EDITOR_SETTINGS.showCurrentStatementFrame,
|
||||
showInsertValueHints: typeof settings.showInsertValueHints === "boolean" ? settings.showInsertValueHints : DEFAULT_EDITOR_SETTINGS.showInsertValueHints,
|
||||
autoAliasTables: settings.autoAliasTables ?? DEFAULT_EDITOR_SETTINGS.autoAliasTables,
|
||||
@@ -1705,6 +1708,7 @@ export const useSettingsStore = defineStore("settings", () => {
|
||||
if (partial.timeoutInheritanceMigrationVersion !== undefined) editorSettings.value.timeoutInheritanceMigrationVersion = Math.max(0, Math.floor(partial.timeoutInheritanceMigrationVersion));
|
||||
if (partial.showExecutionTargetPicker !== undefined) editorSettings.value.showExecutionTargetPicker = partial.showExecutionTargetPicker;
|
||||
if (partial.showStatementRunButtons !== undefined) editorSettings.value.showStatementRunButtons = partial.showStatementRunButtons === true;
|
||||
if (partial.showLineNumbers !== undefined) editorSettings.value.showLineNumbers = partial.showLineNumbers === true;
|
||||
if (partial.showCurrentStatementFrame !== undefined) editorSettings.value.showCurrentStatementFrame = partial.showCurrentStatementFrame === true;
|
||||
if (partial.showInsertValueHints !== undefined) editorSettings.value.showInsertValueHints = partial.showInsertValueHints === true;
|
||||
if (partial.autoAliasTables !== undefined) editorSettings.value.autoAliasTables = partial.autoAliasTables;
|
||||
|
||||
Reference in new issue
Block a user