Skip to content

Fix vi replace with v - #1169

Open
catlover-bot wants to merge 1 commit into
nushell:mainfrom
catlover-bot:fix-vi-replace-v
Open

Fix vi replace with v#1169
catlover-bot wants to merge 1 commit into
nushell:mainfrom
catlover-bot:fix-vi-replace-v

Conversation

@catlover-bot

Copy link
Copy Markdown

Summary

Fix vi normal-mode r<char> replacement when the replacement character is v.

Before

After pressing r in vi normal mode, pressing v entered visual mode instead of completing the pending replace command.

The special-case handling for v ran before the pending multi-key command could consume it.

After

v enters visual mode only when there is no pending vi command. When r is already pending, v is consumed as the replacement character and produces ReplaceChar('v').

A regression test covers the rv sequence while preserving the existing standalone v behavior.

Additional notes

Fixes #1159.

Validation:

  • cargo test edit_mode::vi:: -- --nocapture — 148 passed
  • cargo fmt --all -- --check
  • cargo clippy --locked --all-targets --all-features
  • cargo test --all --all-features -- --test-threads=1 — 1525 passed, 1 ignored; 30 doctests passed
  • git diff --check

@catlover-bot
catlover-bot marked this pull request as ready for review August 18, 2026 16:15
@kronberger-droid

Copy link
Copy Markdown
Collaborator

Looks good.

Some things I would maybe do before we land this:

  • remove the self.cache.clear() since its now a no-op
  • 2v stops entering visual mode, which should at least be documented with a TODO comment and in the PR body.
  • you actually also fix fv and tv. Maybe mention it in the body and add some tests for it.

Thanks for handling 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.

When replacing a character in vi mode, v starts visual mode instead of replacing the character with v

2 participants