mirror of
https://github.com/dreamstarsky/runbin.git
synced 2026-05-15 22:33:09 +00:00
Fix: Revert to 'nearest' scroll behavior to prevent unwanted jumping
This commit is contained in:
@@ -130,11 +130,14 @@ onMounted(() => {
|
|||||||
".cm-scroller": { overflow: "auto" }
|
".cm-scroller": { overflow: "auto" }
|
||||||
}),
|
}),
|
||||||
EditorView.updateListener.of((update) => {
|
EditorView.updateListener.of((update) => {
|
||||||
|
// 只有当文档内容发生改变 且 选区也改变时才触发
|
||||||
if (update.docChanged && update.selectionSet) {
|
if (update.docChanged && update.selectionSet) {
|
||||||
const cursorParams = update.state.selection.main.head;
|
const cursorParams = update.state.selection.main.head;
|
||||||
|
|
||||||
update.view.dispatch({
|
update.view.dispatch({
|
||||||
// 改为 "bottom":强制光标始终露出在视野底部
|
// 🌟 终极方案:只用 nearest
|
||||||
effects: EditorView.scrollIntoView(cursorParams, { y: "bottom" })
|
// 含义:确保光标在视野内。如果在,不动;如果不在,滚进来。
|
||||||
|
effects: EditorView.scrollIntoView(cursorParams, { y: "nearest" })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user