VSCodeVim / VSCodeVim/Vim

Doing `<C-r>:` or `<C-r>q` when `q` is a macro register in insert mode runs the last command instead of printing the command

Open
#4,974 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/macro kind/bug
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
After running a : command if you do <C-r>: in insertMode you should get the command inserted on the editor, but instead it runs the command. Also after recording a macro if you do <C-r>q where 'q' is the register you saved the macro you should get all used keys printed.

To Reproduce
Steps to reproduce the behavior:

With command:

  1. With the text hello world
  2. Run the command :s/world/Vim
  3. You get hello Vim
  4. Now press A<C-R>:
  5. You should get hello Vims/world/Vim

With macro:

  1. Press qqAhello word<BS>ld<Esc>q (here <BS> is the backspace key and <Esc> is the escape key)
  2. Now press o<C-r>q
  3. You get hello wold on the next line and go back to normal mode
  4. You should get hello word<BS>ld<Esc> and still be in insertMode (here the <BS> is actually the four characters and same thing with <Esc>)

Expected behavior
You should get hello word<BS>ld<Esc> and still be in insertMode (here the <BS> is actually the four characters and same thing with <Esc>)

Additional context
I noticed this when fixing the other bug with macros (#4948) that I'm fixing at the moment. I think I know how to fix this one too but I'm going to wait until the PR #4735 gets merged, because if I fix it now it will need to be changed again after that PR is merged.
If you think it is really important to have this before the PR is merged tell me and I'll do it anyway.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the command and macro cases in insert mode, then trace how Ctrl-R handles the command and macro registers. Done means both cases print their contents literally, without executing them, and leave the editor in insert mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.