Skip to content

fix: prevent editor:pageCreating from firing twice in Vim mode#2017

Open
iblamesurya wants to merge 1 commit into
silverbulletmd:mainfrom
iblamesurya:fix/vim-mode-page-creating-double-fire
Open

fix: prevent editor:pageCreating from firing twice in Vim mode#2017
iblamesurya wants to merge 1 commit into
silverbulletmd:mainfrom
iblamesurya:fix/vim-mode-page-creating-double-fire

Conversation

@iblamesurya

Copy link
Copy Markdown
Contributor

When toggling Vim mode, setUiOption calls reloadEditor() which calls loadPage(). For virtual/new pages, loadPage() hits a notFoundError in readPage(), causing editor:pageCreating to fire a second time unexpectedly (issue #2012).

Fix: rebuild the editor state directly using the text already in memory (sliceDoc + createEditorState) instead of going through the full loadPage() path, which avoids re-dispatching editor:pageCreating.

When toggling Vim mode, setUiOption calls reloadEditor() which calls loadPage().
For virtual/new pages, loadPage() hits a notFoundError in readPage(), causing
editor:pageCreating to fire a second time unexpectedly (issue silverbulletmd#2012).

Fix: rebuild the editor state directly using the text already in memory
(sliceDoc + createEditorState) instead of going through the full loadPage()
path, which avoids re-dispatching editor:pageCreating.
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.

1 participant