feat(editor): select sql line from gutter

This commit is contained in:
t8y2
2026-06-03 01:49:35 +08:00
parent 373d5c1ef2
commit 3c93554630
2 changed files with 22 additions and 1 deletions
@@ -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(),
+1
View File
@@ -143,6 +143,7 @@ export function buildEditorFontThemeRules(
zIndex: "10",
},
".cm-lineNumbers .cm-gutterElement": {
cursor: "pointer",
paddingRight: "16px",
userSelect: "none",
},