🐛 Fixed assignment issues
This commit is contained in:
@@ -13,11 +13,11 @@ export function createCursorPositionExtension(documentId: number) {
|
||||
private readonly debouncedSave;
|
||||
|
||||
constructor(private view: EditorView) {
|
||||
const { debouncedFn, flush } = createDebounce(
|
||||
const {debouncedFn, flush} = createDebounce(
|
||||
() => this.saveCursorPosition(),
|
||||
{ delay: 400 }
|
||||
{delay: 400}
|
||||
);
|
||||
this.debouncedSave = { fn: debouncedFn, flush };
|
||||
this.debouncedSave = {fn: debouncedFn, flush};
|
||||
|
||||
// 初始化时保存一次光标位置
|
||||
this.saveCursorPosition();
|
||||
@@ -42,10 +42,11 @@ export function createCursorPositionExtension(documentId: number) {
|
||||
|
||||
private saveCursorPosition() {
|
||||
const cursorPos = this.view.state.selection.main.head;
|
||||
// 持久化到 documentStore
|
||||
this.documentStore.documentStates[documentId] = {
|
||||
cursorPos
|
||||
};
|
||||
if (!this.documentStore.documentStates[documentId]) {
|
||||
this.documentStore.documentStates[documentId] = {cursorPos};
|
||||
} else {
|
||||
this.documentStore.documentStates[documentId].cursorPos = cursorPos;
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user