Obsidian Plugin: SetCursorPosition

49 Views Asked by At

I want to programmatically open a file (via my obsidian plugin) and jump to a specific cursor position. I have tried the following code, it seems that not much is missing:

const editor = this.app.workspace.getActiveViewOfType(MarkdownView).editor;
editor.setSelection(cursor);
editor.focus()

I have tried to add this.app.workspace.updateOptions(), editor.refresh() - but nothing helped - the file is opened but the cursor is always at the start, instead of at the correct cursor position

0

There are 0 best solutions below