esm7/obsidian-vimrc-support

fold and unfold all exmap

DannyDies opened this issue · 5 comments

Hey! Great work with plugins, now vim in obsidian really more useful.

I trying to map fold and unfold all. Console throws type exception.

Uncaught (in promise) TypeError: Cannot read property 'getMode' of undefined
    at editorCheckCallback (app.js:1)
    at VimrcPlugin.eval (eval at <anonymous> (app.js:1), <anonymous>:557:33)
    at step (eval at <anonymous> (app.js:1), <anonymous>:66:23)
    at Object.eval [as next] (eval at <anonymous> (app.js:1), <anonymous>:47:53)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:40:71)
    at new Promise (<anonymous>)
    at __awaiter (eval at <anonymous> (app.js:1), <anonymous>:36:12)
    at Object.eval [as obcommand] (eval at <anonymous> (app.js:1), <anonymous>:541:89)
    at ExCommandDispatcher._processCommand (cm-addons.js:4635)
    at cm-addons.js:4581
esm7 commented

I was unable to get the fold commands to work (perhaps they collide with the Vim mode), but was also unable to recreate the exception that you got.
Can you elaborate more on where you're at? e.g. what's the exact command you're executing, what's the editor status etc?

@esm7 Obsidian v 0.12.4 appimage. installer 0.12.3. Plugin updated for latest versions.
In obsidian edit mode tried to call from vim command mode. Also, mapped to key and tried in normal and visual modes. With opened console and without. Same result - same exception.
command:
:obcommand editor:fold-all
map:

exmap fl obcommand editor:fold-all
" tried also nmap and noremap. 
map <Space>jj :fl

p.s. Strange that defaults za and zc vim fold commands work just fine. The only defaults folding that works.

esm7 commented

Thanks for the details, found the issue and released a fix :)

@esm7 Awesome. Works perfectly. Thanx!

@esm7 Updt: Not perfectly:D
Now it chooses only one opened pane and fold and unfold only within it. No matter what pane is focused on.