diff --git a/README.md b/README.md index ff0fb4b..3c1e420 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,10 @@ See [here](JsSnippets.md) for the full example, and please contribute your own! ## Changelog +### 0.7.1 + +Fixed `jscommand` and `jsfile` broken in the latest Obsidian update. + ### 0.7.0 **IMPORTANT: this version drops support for the legacy (CM5) Obsidian editor.** diff --git a/main.ts b/main.ts index 5b30fce..b06122c 100644 --- a/main.ts +++ b/main.ts @@ -521,7 +521,7 @@ export default class VimrcPlugin extends Plugin { if (jsCode[0] != '{' || jsCode[jsCode.length - 1] != '}') throw new Error("Expected an argument which is JS code surrounded by curly brackets: {...}"); let currentSelections = this.currentSelection; - var chosenSelection = currentSelections[0]; + var chosenSelection = currentSelections && currentSelections.length > 0 ? currentSelections[0] : null; const command = Function('editor', 'view', 'selection', jsCode); const view = this.getActiveView(); command(view.editor, view, chosenSelection); diff --git a/manifest.json b/manifest.json index 8672d67..e9c6ae2 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-vimrc-support", "name": "Vimrc Support", - "version": "0.7.0", + "version": "0.7.1", "description": "Auto-load a startup file with Obsidian Vim commands.", "minAppVersion": "0.15.3", "author": "esm", diff --git a/package.json b/package.json index e1e3b7f..c177788 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vimrc-support", - "version": "0.7.0", + "version": "0.7.1", "description": "Auto-load a startup file with Obsidian Vim commands.", "main": "main.js", "scripts": {