Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: move the cursor to the end after typing up/down arrow key (#10870)

Liu Ji7313121cf237
diff --git a/frontend/src/views/sql-editor/TerminalPanel/CompactSQLEditor.vue b/frontend/src/views/sql-editor/TerminalPanel/CompactSQLEditor.vue
index 621a2ea43b..3d5b17fca7 100644
--- a/frontend/src/views/sql-editor/TerminalPanel/CompactSQLEditor.vue
+++ b/frontend/src/views/sql-editor/TerminalPanel/CompactSQLEditor.vue
@@ -68,7 +68,7 @@ const emit = defineEmits<{
config: ExecuteConfig,
option?: ExecuteOption
): void;
- (e: "history", direction: "up" | "down"): void;
+ (e: "history", direction: "up" | "down", editor: IStandaloneCodeEditor): void;
(e: "clear-screen"): void;
}>();
@@ -243,7 +243,7 @@ const handleEditorReady = (
// - the cursor is at the first line
// - then press "CtrlCmd + Up"
// We trigger the "history" event
- emit("history", "up");
+ emit("history", "up", editor);
},
// Tell the editor this should be only
// triggered when both of the two conditions are satisfied.
@@ -256,7 +256,7 @@ const handleEditorReady = (
// - the cursor is at the last line
// - then press "CtrlCmd + Down"
// We trigger the "history" event
- emit("history", "down");
+ emit("history", "down", editor);
},
// Tell the editor this should be only
// triggered when both of the two conditions are satisfied.
diff --git a/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue b/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
index d0ab5d131f..4e029e442f 100644
--- a/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
+++ b/frontend/src/views/sql-editor/TerminalPanel/TerminalPanelV1.vue
@@ -79,6 +79,7 @@
import { useElementSize } from "@vueuse/core";
import { computed, defineAsyncComponent, ref, unref, watch } from "vue";
import { BBSpin } from "@/bbkit";
+import { IStandaloneCodeEditor } from "@/components/MonacoEditor";
import { useTabStore, useWebTerminalV1Store } from "@/store";
import { ExecuteConfig, ExecuteOption, WebTerminalQueryItemV1 } from "@/types";
import {
@@ -149,11 +150,25 @@ const handleClearScreen = () => {
}
};
-const handleHistory = (direction: "up" | "down") => {
+const handleHistory = (
+ direction: "up" | "down",
+ editor: IStandaloneCodeEditor
+) => {
if (currentQuery.value.status !== "IDLE") {
return;
}
moveHistory(direction);
+
+ requestAnimationFrame(() => {
+ const model = editor.getModel();
+ if (!model) return;
+ const lineNumber = model.getLineCount();
+ const column = model.getLineMaxColumn(lineNumber);
+ editor.setPosition({
+ lineNumber,
+ column,
+ });
+ });
};
const handleCancelQuery = async () => {