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