Skip to content

Conversation

@baodrate
Copy link
Contributor

In obsidian (>=v1.7.2?) the codemirror instance is often not unitialized at times, triggering some uncaught exceptions. This is particularly noticable when:

  • (w/ "Vim chord display" enabled) opening the vault w/o a note opened
  • closing all tabs and opening a note

Add some null guards to avoid these errors

Fixes #237

Some examples of stacktraces caused by unitialized codemirror

Obsidian debug info:

Obsidian version: v1.7.4
Installer version: v1.7.4
Operating system: Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 24.0.0
Login status: logged in
Language: en
Catalyst license: supporter
Insider build toggle: on
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 2
Plugins enabled: 2
	1: Homepage v4.0.7
	2: Vimrc Support v0.10.1
TypeError: Cannot read properties of null (reading 'editMode')
    at VimrcPlugin.getCodeMirror (plugin:obsidian-vimrc-support:755:21)
    at VimrcPlugin.prepareChordDisplay (plugin:obsidian-vimrc-support:1040:33)
    at VimrcPlugin.initialize (plugin:obsidian-vimrc-support:651:14)
    at eval (plugin:obsidian-vimrc-support:720:28)
    at e.tryTrigger (app.js:1:722881)
    at e.trigger (app.js:1:722814)
    at t.trigger (app.js:1:2371835)
    at t.activeLeafEvents (app.js:1:2356506)
    at l (app.js:1:518110)
    at c (app.js:1:518226)
TypeError: Cannot read properties of undefined (reading '_handlers')
    at VimrcPlugin.getCursorActivityHandlers (plugin:obsidian-vimrc-support:690:19)
    at VimrcPlugin.updateSelectionEvent (plugin:obsidian-vimrc-support:682:18)
    at eval (plugin:obsidian-vimrc-support:661:18)
    at e.tryTrigger (app.js:1:722881)
    at e.trigger (app.js:1:722814)
    at t.trigger (app.js:1:2371835)
    at t.activeLeafEvents (app.js:1:2356661)
    at l (app.js:1:518110)
    at c (app.js:1:518226)
TypeError: Cannot read properties of undefined (reading 'off')
    at VimrcPlugin.updateVimEvents (plugin:obsidian-vimrc-support:703:22)
    at eval (plugin:obsidian-vimrc-support:662:18)
    at e.tryTrigger (app.js:1:722881)
    at e.trigger (app.js:1:722814)
    at t.trigger (app.js:1:2371835)
    at t.activeLeafEvents (app.js:1:2356661)
    at l (app.js:1:518110)
    at c (app.js:1:518226)

In obsidian (>=v1.7.2?) the codemirror instance is often not unitialized
at times, triggering some uncaught exceptions. This is particularly
noticable when:

- (w/ "Vim chord display" enabled) opening the vault w/o a note opened
- closing all tabs and opening a note

Add some null guards to avoid these errors
@esm7 esm7 merged commit a5fdaec into esm7:master Oct 31, 2024
@esm7
Copy link
Owner

esm7 commented Oct 31, 2024

Thank you, I will test it and hoping to release a new version in the upcoming days 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught exception when opening vault

2 participants