Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(editor): preserve scroll position after SQL execution

t8y2025b465bf178
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index bfe5e24230..847f667756 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -1469,7 +1469,15 @@ function openReplace(): boolean {
return searchPanelRef.value?.openReplace() ?? false;
}
-defineExpose({ openSearch, openReplace });
+function scrollCursorIntoView() {
+ if (!view.value || !editorViewModule) return;
+ const pos = view.value.state.selection.main.head;
+ view.value.dispatch({
+ effects: editorViewModule.EditorView.scrollIntoView(pos, { y: "nearest" }),
+ });
+}
+
+defineExpose({ openSearch, openReplace, scrollCursorIntoView });
</script>
<template>
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index fb92a2eb18..97cc884d2e 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import { computed, ref, defineAsyncComponent, watch } from "vue";
+import { computed, ref, defineAsyncComponent, watch, nextTick } from "vue";
import { useI18n } from "vue-i18n";
import {
Check,
@@ -171,6 +171,19 @@ watch(
},
);
+watch(
+ () => props.activeTab.isExecuting,
+ (isExecuting, wasExecuting) => {
+ if (!isExecuting && wasExecuting) {
+ nextTick(() => {
+ requestAnimationFrame(() => {
+ queryEditorRef.value?.scrollCursorIntoView();
+ });
+ });
+ }
+ },
+);
+
// Column info panel handlers
async function onHandleClickColumn(
matchedCols: Array<{ name: string; table: string; schema?: string }>,