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
@@ -325,6 +325,7 @@ const executeModeLabel = computed(() => translateWithExecuteShortcut("settings.e
|
||||
const editExecuteAllOnBlankLine = ref(settingsStore.editorSettings.executeAllOnBlankLine);
|
||||
const editShowExecutionTargetPicker = ref(settingsStore.editorSettings.showExecutionTargetPicker);
|
||||
const editShowStatementRunButtons = ref(settingsStore.editorSettings.showStatementRunButtons);
|
||||
const editShowLineNumbers = ref(settingsStore.editorSettings.showLineNumbers);
|
||||
const editShowCurrentStatementFrame = ref(settingsStore.editorSettings.showCurrentStatementFrame);
|
||||
const editShowInsertValueHints = ref(settingsStore.editorSettings.showInsertValueHints);
|
||||
const editAutoAliasTables = ref(settingsStore.editorSettings.autoAliasTables);
|
||||
@@ -526,6 +527,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
|
||||
executeAllOnBlankLine: editExecuteAllOnBlankLine.value,
|
||||
showExecutionTargetPicker: editShowExecutionTargetPicker.value,
|
||||
showStatementRunButtons: editShowStatementRunButtons.value,
|
||||
showLineNumbers: editShowLineNumbers.value,
|
||||
showCurrentStatementFrame: editShowCurrentStatementFrame.value,
|
||||
showInsertValueHints: editShowInsertValueHints.value,
|
||||
autoAliasTables: editAutoAliasTables.value,
|
||||
@@ -812,6 +814,7 @@ function syncEditorSettingsDraftFromStore() {
|
||||
editExecuteAllOnBlankLine.value = settingsStore.editorSettings.executeAllOnBlankLine;
|
||||
editShowExecutionTargetPicker.value = settingsStore.editorSettings.showExecutionTargetPicker;
|
||||
editShowStatementRunButtons.value = settingsStore.editorSettings.showStatementRunButtons;
|
||||
editShowLineNumbers.value = settingsStore.editorSettings.showLineNumbers;
|
||||
editShowCurrentStatementFrame.value = settingsStore.editorSettings.showCurrentStatementFrame;
|
||||
editShowInsertValueHints.value = settingsStore.editorSettings.showInsertValueHints;
|
||||
editAutoAliasTables.value = settingsStore.editorSettings.autoAliasTables;
|
||||
@@ -1063,6 +1066,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
|
||||
editExecuteAllOnBlankLine.value = DEFAULT_EDITOR_SETTINGS.executeAllOnBlankLine;
|
||||
editShowExecutionTargetPicker.value = DEFAULT_EDITOR_SETTINGS.showExecutionTargetPicker;
|
||||
editShowStatementRunButtons.value = DEFAULT_EDITOR_SETTINGS.showStatementRunButtons;
|
||||
editShowLineNumbers.value = DEFAULT_EDITOR_SETTINGS.showLineNumbers;
|
||||
editShowCurrentStatementFrame.value = DEFAULT_EDITOR_SETTINGS.showCurrentStatementFrame;
|
||||
editShowInsertValueHints.value = DEFAULT_EDITOR_SETTINGS.showInsertValueHints;
|
||||
editAutoAliasTables.value = DEFAULT_EDITOR_SETTINGS.autoAliasTables;
|
||||
@@ -1175,6 +1179,7 @@ function resetAllDefaults() {
|
||||
editExecuteAllOnBlankLine.value = DEFAULT_EDITOR_SETTINGS.executeAllOnBlankLine;
|
||||
editShowExecutionTargetPicker.value = DEFAULT_EDITOR_SETTINGS.showExecutionTargetPicker;
|
||||
editShowStatementRunButtons.value = DEFAULT_EDITOR_SETTINGS.showStatementRunButtons;
|
||||
editShowLineNumbers.value = DEFAULT_EDITOR_SETTINGS.showLineNumbers;
|
||||
editShowCurrentStatementFrame.value = DEFAULT_EDITOR_SETTINGS.showCurrentStatementFrame;
|
||||
editShowInsertValueHints.value = DEFAULT_EDITOR_SETTINGS.showInsertValueHints;
|
||||
editAutoAliasTables.value = DEFAULT_EDITOR_SETTINGS.autoAliasTables;
|
||||
@@ -3938,6 +3943,16 @@ onUnmounted(() => {
|
||||
<Switch id="editor-show-statement-run-buttons" v-model="editShowStatementRunButtons" class="mt-0.5" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<div class="space-y-1">
|
||||
<Label for="editor-show-line-numbers">{{ t("settings.showLineNumbers") }}</Label>
|
||||
<p class="text-xs text-muted-foreground">
|
||||
{{ t("settings.showLineNumbersDescription") }}
|
||||
</p>
|
||||
</div>
|
||||
<Switch id="editor-show-line-numbers" v-model="editShowLineNumbers" class="mt-0.5" />
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between gap-4 rounded-md border bg-muted/20 px-3 py-2">
|
||||
<div class="space-y-1">
|
||||
<Label for="editor-show-current-statement-frame">{{ t("settings.showCurrentStatementFrame") }}</Label>
|
||||
|
||||
@@ -107,6 +107,7 @@ import type { SqlHighlighter } from "@/lib/sql/sqlHighlighter";
|
||||
import { EDITOR_FONT_FAMILY_CSS_VAR, EDITOR_FONT_SIZE_CSS_VAR, editorDiagnosticColors, editorThemeAppearanceFor, loadEditorTheme, editorFontTheme, shellLineCommentTheme, sqlCompletionTheme, sqlSemanticHighlightTheme } from "@/lib/editor/editorThemes";
|
||||
import { createStatementGutterMarkerDom, shouldShowStatementGutter } from "@/lib/editor/codemirrorStatementGutter";
|
||||
import { createQueryEditorSearchKeymap } from "@/lib/editor/queryEditorSearchKeymap";
|
||||
import { buildQueryEditorLineNumbersExtension } from "@/lib/editor/queryEditorLineNumbers";
|
||||
import { searchKeymapWithoutModD } from "@/lib/editor/codemirrorSearchKeymap";
|
||||
import { defaultKeymapForGlobalShortcuts } from "@/lib/editor/codemirrorDefaultKeymap";
|
||||
import { appendSqlCompletionSpace } from "@/lib/editor/sqlCompletionInsertion";
|
||||
@@ -512,12 +513,14 @@ interface EditorGestureEvent extends Event {
|
||||
}
|
||||
|
||||
let editorViewModule: typeof import("@codemirror/view") | null = null;
|
||||
let codeMirrorLineNumbers: typeof import("@codemirror/view").lineNumbers | null = null;
|
||||
let codeMirrorPrec: typeof import("@codemirror/state").Prec | null = null;
|
||||
let codeMirrorEditorSelection: typeof import("@codemirror/state").EditorSelection | null = null;
|
||||
let hoverCloseEffect: StateEffect<unknown> | null = null;
|
||||
let fontThemeComp: import("@codemirror/state").Compartment | null = null;
|
||||
let codeMirrorTheme: import("@codemirror/state").Compartment | null = null;
|
||||
let wordWrapComp: import("@codemirror/state").Compartment | null = null;
|
||||
let lineNumbersComp: import("@codemirror/state").Compartment | null = null;
|
||||
let vimModeComp: import("@codemirror/state").Compartment | null = null;
|
||||
let closeBracketsComp: import("@codemirror/state").Compartment | null = null;
|
||||
let sqlLanguageComp: import("@codemirror/state").Compartment | null = null;
|
||||
@@ -694,6 +697,7 @@ const queryEditorAppearanceSettings = computed(() => {
|
||||
autoCloseBrackets: settings.autoCloseBrackets,
|
||||
showCurrentStatementFrame: settings.showCurrentStatementFrame,
|
||||
showInsertValueHints: settings.showInsertValueHints,
|
||||
showLineNumbers: settings.showLineNumbers,
|
||||
shortcuts: settings.shortcuts,
|
||||
showStatementRunButtons: settings.showStatementRunButtons,
|
||||
};
|
||||
@@ -2053,6 +2057,14 @@ function wordWrapExtension() {
|
||||
return props.forceWordWrap || settingsStore.editorSettings.wordWrap ? editorViewModule.EditorView.lineWrapping : [];
|
||||
}
|
||||
|
||||
function lineNumbersExtension(enabled = settingsStore.editorSettings.showLineNumbers) {
|
||||
return buildQueryEditorLineNumbersExtension(codeMirrorLineNumbers, enabled, {
|
||||
domEventHandlers: {
|
||||
mousedown: selectSqlLineFromGutter,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function closeBracketsExtension(enabled = settingsStore.editorSettings.autoCloseBrackets) {
|
||||
if (!enabled || !codeMirrorCloseBrackets) return [];
|
||||
const exts: import("@codemirror/state").Extension[] = [codeMirrorCloseBrackets()];
|
||||
@@ -4649,12 +4661,14 @@ onMounted(async () => {
|
||||
rectangularSelection,
|
||||
} as typeof import("@codemirror/view");
|
||||
hoverCloseEffect = closeHoverTooltips;
|
||||
codeMirrorLineNumbers = lineNumbers;
|
||||
codeMirrorPrec = Prec;
|
||||
codeMirrorEditorSelection = EditorSelection;
|
||||
codeMirrorSnippetCompletion = snippetCompletion;
|
||||
fontThemeComp = new Compartment();
|
||||
codeMirrorTheme = new Compartment();
|
||||
wordWrapComp = new Compartment();
|
||||
lineNumbersComp = new Compartment();
|
||||
vimModeComp = new Compartment();
|
||||
closeBracketsComp = new Compartment();
|
||||
sqlLanguageComp = new Compartment();
|
||||
@@ -5115,11 +5129,7 @@ onMounted(async () => {
|
||||
scrollToMatch: (range) => EditorView.scrollIntoView(range, { y: "center" }),
|
||||
}),
|
||||
runGutterComp.of(runStatementGutterExtension()),
|
||||
lineNumbers({
|
||||
domEventHandlers: {
|
||||
mousedown: selectSqlLineFromGutter,
|
||||
},
|
||||
}),
|
||||
lineNumbersComp.of(lineNumbersExtension(initialSettings.showLineNumbers)),
|
||||
currentStatementFrameExtension,
|
||||
highlightActiveLineGutter(),
|
||||
highlightSpecialChars(),
|
||||
@@ -5763,7 +5773,7 @@ function getCurrentCustomThemeColors() {
|
||||
watch(
|
||||
[queryEditorAppearanceSettings, () => isDark.value, () => themePalette.value, editorThemeAppearance],
|
||||
async ([ss]) => {
|
||||
if (!view.value || !codeMirrorTheme || !fontThemeComp || !wordWrapComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
if (!view.value || !codeMirrorTheme || !fontThemeComp || !wordWrapComp || !lineNumbersComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
return;
|
||||
}
|
||||
if (!isGestureZooming.value && !zoomCommitScheduler.hasPendingCommit() && liveFontSize.value !== ss.fontSize) {
|
||||
@@ -5773,13 +5783,14 @@ watch(
|
||||
syncEditorDiagnosticCssVars();
|
||||
const themeColors = getCurrentCustomThemeColors();
|
||||
const [themeExt] = await Promise.all([loadEditorTheme(ss.theme, editorThemeAppearance(), themeColors, themePalette.value), ss.vimModeEnabled ? ensureCodeMirrorVim() : Promise.resolve(false)]);
|
||||
if (!view.value || !codeMirrorTheme || !wordWrapComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
if (!view.value || !codeMirrorTheme || !wordWrapComp || !lineNumbersComp || !vimModeComp || !closeBracketsComp || !runGutterComp || !runKeymapComp || !editorViewModule) {
|
||||
return;
|
||||
}
|
||||
view.value.dispatch({
|
||||
effects: [
|
||||
codeMirrorTheme.reconfigure(themeExt),
|
||||
wordWrapComp.reconfigure(props.forceWordWrap || ss.wordWrap ? editorViewModule.EditorView.lineWrapping : []),
|
||||
lineNumbersComp.reconfigure(lineNumbersExtension(ss.showLineNumbers)),
|
||||
vimModeComp.reconfigure(vimModeExtension(settingsStore.editorSettings.vimModeEnabled)),
|
||||
closeBracketsComp.reconfigure(closeBracketsExtension(settingsStore.editorSettings.autoCloseBrackets)),
|
||||
runGutterComp.reconfigure(runStatementGutterExtension()),
|
||||
|
||||
Reference in new issue
Block a user