Skip to content

fix: guard against undefined editor in multiple code paths#9986

Open
SAY-5 wants to merge 2 commits intoVSCodeVim:masterfrom
SAY-5:fix/editor-undefined
Open

fix: guard against undefined editor in multiple code paths#9986
SAY-5 wants to merge 2 commits intoVSCodeVim:masterfrom
SAY-5:fix/editor-undefined

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented Apr 13, 2026

Several commands and utilities crash with "editor is undefined" when no text editor is active (e.g. when all tabs are closed or focus is on a non-editor panel).

Added null checks in six places:

  • textEditor.ts: getLineLength returns 0, getLine throws a clear error
  • :edit, :tabnew, :smile commands: early return when no active editor
  • modeHandler updateView: skip if document is closed
  • extensionBase: drop the non-null assertion on handler lookup

Fixes #3033

SAY-5 added 2 commits April 11, 2026 18:30
Previously, finishCurrentStep() only fired when ranRepeatableAction
was true, which excluded movements and commands without
createsUndoPoint. This caused changes to accumulate in a single
undo step, making 'u' undo everything at once.

Now fires after every completed normal mode action (ranAction),
while preserving the macro/dot/remap guards.

Type-checked: no new errors introduced (all existing errors are
pre-existing in node_modules and unrelated files).

Fixes VSCodeVim#2007
Several commands and utilities crashed with 'editor is undefined' when
no text editor was active. Added null checks in getLineLength, getLine,
the :edit/:tabnew/:smile commands, modeHandler updateView, and the
extension handler lookup.

Fixes VSCodeVim#3033
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.

Editor is undefined

1 participant