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): center search matches in the viewport

Melody Ruchb8d37774fdad
diff --git a/apps/desktop/src/components/editor/EditorSearchPanel.vue b/apps/desktop/src/components/editor/EditorSearchPanel.vue
index 4d0187b7f6..6a16248ff1 100644
--- a/apps/desktop/src/components/editor/EditorSearchPanel.vue
+++ b/apps/desktop/src/components/editor/EditorSearchPanel.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, nextTick, onBeforeUnmount, watch } from "vue";
import { useI18n } from "vue-i18n";
-import type { EditorView } from "@codemirror/view";
+import { EditorView } from "@codemirror/view";
import { EditorSelection } from "@codemirror/state";
import { setSearchQuery, openSearchPanel as cmOpenSearchPanel, findNext as cmFindNext, findPrevious as cmFindPrevious, replaceNext as cmReplaceNext, replaceAll as cmReplaceAll } from "@codemirror/search";
import { ChevronUp, ChevronDown, ChevronRight, TextSelect, X } from "@lucide/vue";
@@ -171,7 +171,10 @@ function findInScope(direction: "next" | "prev"): boolean {
if (target) {
v.dispatch({
selection: EditorSelection.range(target.from, target.to),
- scrollIntoView: true,
+ // Center the match instead of the default "nearest" alignment, which
+ // often lands the match flush against the viewport edge and makes an
+ // immediate drag-select there trigger CodeMirror's edge autoscroll.
+ effects: EditorView.scrollIntoView(target.from, { y: "center" }),
});
return true;
}
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index b11dfa36fe..0a202e2dff 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -4679,6 +4679,10 @@ onMounted(async () => {
dom.style.display = "none";
return { dom };
},
+ // Center the match instead of the default "nearest" alignment, which
+ // often lands the match flush against the viewport edge and makes an
+ // immediate drag-select there trigger CodeMirror's edge autoscroll.
+ scrollToMatch: (range) => EditorView.scrollIntoView(range, { y: "center" }),
}),
runGutterComp.of(runStatementGutterExtension()),
lineNumbers({