Fix jumping cursor

This commit is contained in:
Andras Schmelczer 2025-03-29 13:36:32 +00:00
parent 3bbc5c61e9
commit 52bda89764
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 5 additions and 1 deletions

View file

@ -27,7 +27,9 @@ export class ObsidianFileSystemOperations implements FileSystemOperations {
const view = this.workspace.getActiveViewOfType(MarkdownView);
if (view?.file?.path === path) {
const position = view.editor.getCursor();
view.editor.setValue(new TextDecoder().decode(content));
view.editor.setCursor(position);
return;
}
@ -47,7 +49,9 @@ export class ObsidianFileSystemOperations implements FileSystemOperations {
const view = this.workspace.getActiveViewOfType(MarkdownView);
if (view?.file?.path === path) {
const result = updater(view.editor.getValue());
const position = view.editor.getCursor();
view.editor.setValue(result);
view.editor.setCursor(position);
return result;
}

View file

@ -167,6 +167,6 @@ export default class VaultLinkPlugin extends Plugin {
)
);
}
await this.rateLimitedUpdatesPerFile.get(path)();
await this.rateLimitedUpdatesPerFile.get(path)?.();
}
}