mirror of
https://github.com/esm7/obsidian-vimrc-support.git
synced 2026-07-22 05:00:25 +00:00
parent
361c2686da
commit
ccbaaefc23
1 changed files with 11 additions and 5 deletions
16
main.ts
16
main.ts
|
|
@ -85,6 +85,9 @@ export default class VimrcPlugin extends Plugin {
|
|||
this.app.workspace.on("window-open", (workspaceWindow, w) => {
|
||||
this.registerYankEvents(w);
|
||||
})
|
||||
this.app.workspace.on("file-open", async (cm: any) => {
|
||||
this.registerFileOpenEvent();
|
||||
})
|
||||
|
||||
this.initialized = true;
|
||||
}
|
||||
|
|
@ -101,6 +104,14 @@ export default class VimrcPlugin extends Plugin {
|
|||
})
|
||||
}
|
||||
|
||||
registerFileOpenEvent(){
|
||||
// Record the position of selections in each file opened
|
||||
let cmEditor = this.getCodeMirror(this.getActiveView());
|
||||
CodeMirror.on(cmEditor, "cursorActivity", async (cm: any) => {
|
||||
this.currentSelection = cm.listSelections();
|
||||
});
|
||||
}
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new SettingsTab(this.app, this))
|
||||
|
|
@ -182,11 +193,6 @@ export default class VimrcPlugin extends Plugin {
|
|||
this.defineJsCommand(this.codeMirrorVimObject);
|
||||
this.defineJsFile(this.codeMirrorVimObject);
|
||||
|
||||
// Record the position of selections
|
||||
CodeMirror.on(cmEditor, "cursorActivity", async (cm: any) => {
|
||||
this.currentSelection = cm.listSelections()
|
||||
});
|
||||
|
||||
vimCommands.split("\n").forEach(
|
||||
function (line: string, index: number, arr: [string]) {
|
||||
if (line.trim().length > 0 && line.trim()[0] != '"') {
|
||||
|
|
|
|||
Loading…
Reference in a new issue