VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.97k stars 1.32k forks source link

Pressing Key sequence ci( or ci[ of ci{ at beginning of sentence does not jump cursor into parenthesis, bracket or brace pair #7346

Open PatrickNH opened 2 years ago

PatrickNH commented 2 years ago

Describe the bug In normal mode when pressing the key sequence ci( or ci[ of ci{, the cursor does not jump to after the opening parenthesis, bracket or brace and does not remove the word in the parenthesis, bracket or brace pair and change to insert mode. In the Vim editor, the key sequence works. Note: when the cursor is on the opening or closing parenthesis, bracket or brace, or when inside the parenthesis, bracket or brace pair then the ci( key sequence does work but this should work anywhere before a parenthesis, bracket or brace pair.

To Reproduce Steps to reproduce the behavior:

  1. Install / enable extension: Vim emulation for Visual Studio Code v1.21.10
  2. Install / enable extension: Python v2021.12.1559732655
  3. Create a python file: test.py
  4. Enter a sample line in the file: This is a test sentence with a (sample) word in parentheses.
  5. Save the file
  6. In Vim normal mode press the 0 key to go to the beginning of the sentence
  7. In Vim normal mode press the key sequence: ci(

Expected behavior In normal mode, when pressing the key sequence ci{ or ci[ or CI{ at the beginning of the sentence, the cursor should jump into the nearest parentheses, curly braces or bracket pair, empty the pairs and change to insert mode.

Screenshots If applicable, add screenshots to help explain your problem. If remapping-related, please attach log output: https://github.com/VSCodeVim/Vim#debugging-remappings.

Environment (please complete the following information):

Additional context Add any other context about the problem here.

J-Fields commented 2 years ago

Last I checked, this was expected behavior in Vim, but neovim does handle it this way (which is almost unarguably more consistent and intuitive), so it probably would be good to implement.

elazarcoh commented 2 years ago

I have it implemented for the targets plugin (not yet released), but only by typing cin( (n stands for "next"). ~It's here: https://github.com/elazarcoh/Vim/tree/last-next-object. I intend to make a PR out of it, after version 1.23 will be released.~ PR had been submitted: #7558 Also, it's not exactly the same behavior, because if you're inside prens objects then it'll jump to the next one instead of editing the current one.

@J-Fields I think I can refactor this logic out of the targets plugin, if you think it's something we want.

with ci( I expect it to jump to the prens object only if it starts in the current line, is that right?