diff --git a/src/App.vue b/src/App.vue index 675937125c..8aa3a8995f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -124,6 +124,7 @@ const showUpdateDialog = ref(false); const dangerSql = ref(""); const pendingDangerSql = ref(""); const selectedSql = ref(""); +const cursorPos = ref(0); const formatSqlRequestId = ref(0); const activeOutputView = ref<"result" | "explain">("result"); const showDangerDialog = ref(false); @@ -455,7 +456,10 @@ const activeTab = computed(() => const executableSql = computed(() => { const tab = activeTab.value; - return tab ? resolveExecutableSql(tab.sql, selectedSql.value) : ""; + return tab ? resolveExecutableSql(tab.sql, selectedSql.value, { + mode: settingsStore.editorSettings.executeMode, + cursorPos: cursorPos.value, + }) : ""; }); watch(() => queryStore.activeTabId, () => { @@ -615,6 +619,10 @@ function onEditorSelectionChange(val: string) { selectedSql.value = val; } +function onEditorCursorChange(pos: number) { + cursorPos.value = pos; +} + function formatActiveSql() { const tab = activeTab.value; if (!tab || tab.mode !== "query" || !tab.sql.trim()) return; @@ -1464,6 +1472,7 @@ async function setupFileDrop() { :format-request-id="formatSqlRequestId" @update:model-value="onEditorUpdate" @selection-change="onEditorSelectionChange" + @cursor-change="onEditorCursorChange" @format-error="onFormatSqlError" @execute="tryExecute" /> diff --git a/src/components/editor/EditorSettingsDialog.vue b/src/components/editor/EditorSettingsDialog.vue index 6c2562001b..85ba8cedae 100644 --- a/src/components/editor/EditorSettingsDialog.vue +++ b/src/components/editor/EditorSettingsDialog.vue @@ -32,6 +32,7 @@ const emit = defineEmits<{ const editFontFamily = ref(settingsStore.editorSettings.fontFamily); const editFontSize = ref(settingsStore.editorSettings.fontSize); const editTheme = ref(settingsStore.editorSettings.theme); +const editExecuteMode = ref(settingsStore.editorSettings.executeMode); // Sync from store when dialog opens watch(() => props.open, (open) => { @@ -39,6 +40,7 @@ watch(() => props.open, (open) => { editFontFamily.value = settingsStore.editorSettings.fontFamily; editFontSize.value = settingsStore.editorSettings.fontSize; editTheme.value = settingsStore.editorSettings.theme; + editExecuteMode.value = settingsStore.editorSettings.executeMode; } }); @@ -46,7 +48,8 @@ function hasChanges(): boolean { return ( editFontFamily.value !== settingsStore.editorSettings.fontFamily || editFontSize.value !== settingsStore.editorSettings.fontSize || - editTheme.value !== settingsStore.editorSettings.theme + editTheme.value !== settingsStore.editorSettings.theme || + editExecuteMode.value !== settingsStore.editorSettings.executeMode ); } @@ -55,6 +58,7 @@ function applySettings() { fontFamily: editFontFamily.value, fontSize: editFontSize.value, theme: editTheme.value, + executeMode: editExecuteMode.value, }); emit("update:open", false); } @@ -63,6 +67,11 @@ function resetDefaults() { editFontFamily.value = DEFAULT_EDITOR_SETTINGS.fontFamily; editFontSize.value = DEFAULT_EDITOR_SETTINGS.fontSize; editTheme.value = DEFAULT_EDITOR_SETTINGS.theme; + editExecuteMode.value = DEFAULT_EDITOR_SETTINGS.executeMode; +} + +function onExecuteModeChange(v: any) { + if (v === "all" || v === "current") editExecuteMode.value = v; } function onFontFamilyChange(v: any) { @@ -160,7 +169,7 @@ watch(() => props.open, (open) => {