obsidian-vimrc-support icon indicating copy to clipboard operation
obsidian-vimrc-support copied to clipboard

:surround doesn't work properly when obsidian is first opened?

Open sersorrel opened this issue 2 years ago • 0 comments

If I open obsidian and immediately press [[, the document doesn't change, and I get this error:

app.js:1 TypeError: Cannot read properties of null (reading '0')
    at surroundFunc (eval at <anonymous> (app.js:1), <anonymous>:783:52)

Apparently this is caused here:

https://github.com/esm7/obsidian-vimrc-support/blob/9f9898abac1c7bbd951a192181c05767e0558a02/main.ts#L368

This is kind of a pain to reproduce since clicking at all in the document (even on the place where the cursor currently is) stops it happening; devtools "focus debuggee" was useful for me.

My config looks like this:

nmap j gj
nmap k gk
exmap wikilink surround [[ ]]
nmap [[ :wikilink
vmap [[ :wikilink
exmap paren surround ( )
vmap Sb :paren
vmap S( :paren
vmap S) :paren
exmap square surround [ ]
vmap S[ :square
vmap S] :square
exmap curly surround { }
vmap SB :curly
vmap S{ :curly
vmap S} :curly
the full console log
Obsidian Developer Console
app.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
n @ app.js:1
e @ app.js:1
e @ app.js:1
e @ app.js:1
t @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.setViewState @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.deserializeLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.deserializeLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.setLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
s @ app.js:1
Show 4 more frames
app.js:1 [Violation] Added non-passive event listener to a scroll-blocking 'touchmove' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952
n @ app.js:1
e @ app.js:1
e @ app.js:1
e @ app.js:1
t @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.setViewState @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.deserializeLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.deserializeLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
A @ app.js:1
t.setLayout @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
(anonymous) @ app.js:1
s @ app.js:1
Show 4 more frames
main.ts:88 Vimrc plugin: using CodeMirror 6 mode
vim.js:977 TypeError: Cannot read properties of null (reading '0')
    at surroundFunc (eval at <anonymous> (app.js:1), <anonymous>:783:52)
    at Object.eval [as surround] (eval at <anonymous> (app.js:1), <anonymous>:826:68)
    at ExCommandDispatcher._processCommand (vim.js:4654)
    at vim.js:4600
    at e.operation (app.js:1)
    at ExCommandDispatcher.processCommand (vim.js:4598)
    at Object.handleEx (vim.js:987)
    at Object.eval [as wikilink] (eval at <anonymous> (app.js:1), <anonymous>:657:43)
    at ExCommandDispatcher._processCommand (vim.js:4654)
    at vim.js:4600
app.js:1 TypeError: Cannot read properties of null (reading '0')
    at surroundFunc (eval at <anonymous> (app.js:1), <anonymous>:783:52)
    at Object.eval [as surround] (eval at <anonymous> (app.js:1), <anonymous>:826:68)
    at ExCommandDispatcher._processCommand (vim.js:4654)
    at vim.js:4600
    at e.operation (app.js:1)
    at ExCommandDispatcher.processCommand (vim.js:4598)
    at Object.handleEx (vim.js:987)
    at Object.eval [as wikilink] (eval at <anonymous> (app.js:1), <anonymous>:657:43)
    at ExCommandDispatcher._processCommand (vim.js:4654)
    at vim.js:4600
keydown @ app.js:1
e.runCustomHandlers @ app.js:1
(anonymous) @ app.js:1
app.js:1 

sersorrel avatar Apr 13 '22 02:04 sersorrel