Repository navigation
Fix broken vim ex commands (:w, :wq, :q!, line jumps) - #739
Merged
Merged
Conversation
The :w command dispatched a vim-save window event that had no listener,
so saving through ex commands never worked. :wq also relied on that dead
event and then closed the buffer on a 100ms timer, which raced the save
and could pop an unsaved-changes prompt right after a write. :{line}
dispatched vim-goto-line, another event without a listener, so jumping
to a line number did nothing. :q! called the same close path as :q and
still showed the confirmation prompt for dirty buffers.
:w now calls the same handleSave action as the editor save shortcut.
:wq awaits the save before closing, removing the timer race. :q! uses
the force-close action to discard changes without prompting. :{line}
dispatches menu-go-to-line, the event the editor already listens to for
go-to-line requests from search, diagnostics, and other surfaces.
Adds regression tests for all five commands under src/features/vim/tests.
Return the active save result and capture the originating buffer before awaiting it. Failed or canceled writes now leave that buffer open, and tab switches cannot redirect the close to another buffer.
mehmetozguldev
self-requested a review
August 25, 2026 13:51
mehmetozguldev
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix broken vim ex commands (:w, :wq, :q!, line jumps)
Problem
The vim ex commands in
src/features/vim/stores/vim-commands.tsdispatched window events that no code in the repo listens to::wdispatched avim-saveCustomEvent with zero listeners, so it silently did nothing.:wq/:xdispatched the same dead event, then closed the buffer on asetTimeout(100)timer. The timer races the save that never happens; on a dirty buffer this pops an unsaved-changes dialog instead of saving and closing.:{line}dispatchedvim-goto-line, also with no listener, so jumping to a line number did nothing.:q!calledcloseBuffer(), exactly like:q, so force-quit still showed the save confirmation on dirty buffers.Fix
:wnow callsuseEditorAppStore.getState().actions.handleSave()directly, the same action the editor save shortcut uses.:wq/:xawait the save before closing, which also removes thesetTimeoutrace.:q!now uses the existingcloseBufferForce()action to discard changes without prompting.:{line}dispatchesmenu-go-to-line, the event the editor surface already listens to for go-to-line requests from search results, diagnostics, the debugger, and the status bar.Also removes a dead trailing comment left after an autocomplete helper.
Testing
Adds
src/features/vim/tests/vim-commands.test.tswith regression tests for all five commands (written failing-first). Full suite passes: 358 files, 1756 tests.Note:
bun checkreports pre-existingcargo fmtdiffs incrates/toolingon a clean checkout ofmainas well (stable rustfmt cannot apply the nightly-only options inrustfmt.toml). The TypeScript checks, lint, architecture checks, and tests all pass on this branch.I agree to the Contributor License and Feedback Agreement.