Skip to content

fix(vi): enter visual mode through command#1089

Closed
matystroia wants to merge 1 commit into
nushell:mainfrom
matystroia:vi-mode-visual-command
Closed

fix(vi): enter visual mode through command#1089
matystroia wants to merge 1 commit into
nushell:mainfrom
matystroia:vi-mode-visual-command

Conversation

@matystroia

Copy link
Copy Markdown

Problem:

Entering visual mode does not actually select char/grapheme under cursor. Thus you have to do something like vlh to actually move selection to cursor. This happens because the parser eats the v input and sets mode manually instead of it going through the usual Command -> EditCommand pipeline.

Solution:

  • Add EditCommand::SelectChar that sets selection anchor to current cursor position
  • Add Command::EnterViVisual that maps to EditCommand::SelectChar

Mode change still happens in parser, but now through the return value of changes_mode.

@kronberger-droid

Copy link
Copy Markdown
Collaborator

One behavior shift worth knowing about is that the old v path emitted ReedlineEvent::Esc, which closed any open menus. The new path skips that, could you preserve it by changing Command::EnterViVisual mapping:

Self::EnterViVisual => vec![
    ReedlineOption::Event(ReedlineEvent::Esc),
    ReedlineOption::Edit(EditCommand::SelectChar),
],

Also a couple of test before merge?

  • Editor-level: EditCommand::SelectChar sets selection_anchor
  • End-to-end: v then U on a fresh buffer capitalizes the grapheme under the cursor etc.

Also the EditCommand::SelectChar has a trailing comma.

Afterwards I am fine with landing it.

@matystroia
matystroia force-pushed the vi-mode-visual-command branch from e9b966e to 9b7f565 Compare June 11, 2026 17:05
@matystroia
matystroia force-pushed the vi-mode-visual-command branch from 9b7f565 to 2c26beb Compare June 11, 2026 17:35
@kronberger-droid

Copy link
Copy Markdown
Collaborator

Hey sorry for not letting you know up front. These kind of bugs will be solved in a follow up of #1100, which will hopefully coming soon.
Still thanks for pointing it out and giving a lead on how to solve this.

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.

2 participants