Skip to content

Commit

Permalink
fix: set source mode line navigation
Browse files Browse the repository at this point in the history
close #91
  • Loading branch information
Vinzent03 committed Nov 24, 2022
1 parent d66e6a9 commit e1079a3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ export default class AdvancedURI extends Plugin {
file: parameters.filepath,
setting: this.settings.openFileWithoutWriteInNewPane,
parameters: parameters,
mode: parameters.line != undefined ? "source" : undefined
});
if (parameters.line != undefined) {
this.setCursorInLine(parameters.line);
Expand Down Expand Up @@ -746,6 +747,12 @@ export default class AdvancedURI extends Plugin {
setCursorInLine(rawLine: number) {
const view = this.app.workspace.getActiveViewOfType(MarkdownView);
if (!view) return;
const viewState = view.leaf.getViewState();
if (viewState.state.mode !== "source") {
viewState.state.mode = "source";
view.leaf.setViewState(viewState);
}

const line = Math.min(rawLine - 1, view.editor.lineCount() - 1);
view.editor.focus();
view.editor.setCursor({ line: line, ch: view.editor.getLine(line).length });
Expand Down

0 comments on commit e1079a3

Please sign in to comment.