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。

feat(editor): select sql line from gutter

t8y23c9355463001
diff --git a/apps/desktop/src/components/editor/QueryEditor.vue b/apps/desktop/src/components/editor/QueryEditor.vue
index 0a5ef7a22c..c63df89d3c 100644
--- a/apps/desktop/src/components/editor/QueryEditor.vue
+++ b/apps/desktop/src/components/editor/QueryEditor.vue
@@ -331,6 +331,22 @@ function selectAllSqlFromContextMenu() {
focusEditor();
}
+function selectSqlLineFromGutter(
+ currentView: EditorViewType,
+ line: { from: number; to: number },
+ event: Event,
+): boolean {
+ if (!(event instanceof MouseEvent) || event.button !== 0) return false;
+ event.preventDefault();
+ currentView.dispatch({
+ selection: { anchor: line.from, head: line.to },
+ scrollIntoView: true,
+ userEvent: "select.pointer",
+ });
+ currentView.focus();
+ return true;
+}
+
const contextMenuItems = computed<ContextMenuItem[]>(() => [
{
label: executeContextMenuLabel.value,
@@ -1324,7 +1340,11 @@ onMounted(async () => {
return { dom };
},
}),
- lineNumbers(),
+ lineNumbers({
+ domEventHandlers: {
+ mousedown: selectSqlLineFromGutter,
+ },
+ }),
highlightActiveLineGutter(),
highlightSpecialChars(),
history(),
diff --git a/apps/desktop/src/lib/editorThemes.ts b/apps/desktop/src/lib/editorThemes.ts
index 0a36841ea9..b0358b57aa 100644
--- a/apps/desktop/src/lib/editorThemes.ts
+++ b/apps/desktop/src/lib/editorThemes.ts
@@ -143,6 +143,7 @@ export function buildEditorFontThemeRules(
zIndex: "10",
},
".cm-lineNumbers .cm-gutterElement": {
+ cursor: "pointer",
paddingRight: "16px",
userSelect: "none",
},