fix(editor): preserve scroll position after SQL execution
After DDL/DML execution via the danger confirmation dialog, the editor scrolls to the top, making it hard to locate the executed statement. Fix by scrolling the cursor back into view after execution completes, using nextTick + requestAnimationFrame to wait for Splitpanes layout stabilization.
This commit is contained in:
parent
9aae48d089
commit
025b465bf1
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 }>,
|
||||
|
|
|
|||
Loading…
Reference in New Issue