VSCodeVim / VSCodeVim/Vim

Change inside does not move cursor correctly when surrounding characters are before current position

Open
#8,449 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
ci] and alikes don't move cursor to correct position when cursor is initially positioned after the pair characters.

To Reproduce
Steps to reproduce the behavior:

  1. Copy paste this line of code:
var myArray = [ "Hello", "world" ]; // This is some array.
  1. Move cursor to comment:
var myArray = [ "Hello", "world" ]; // This is some array.
//---------------------------------------^
  1. Execute ci] command.
  2. ✅ The brackets are cleared, ✅ the mode is changed to insert, but ❌ the cursor stays in place.
var myArray = []; // This is some array.
//---------------------^

Expected behavior
The cursor is moved to be inside of the brackets.

Environment (please complete the following information):

Extension version: 1.25.2
VS Code version: Code 1.77.3 (704ed70d4fd1c6bd6342c436f1ede30d1cff4710, 2023-04-12T09:16:52.732Z)
OS version: Linux x64 5.19.0-41-generic

Additional context

  • This goes for all types of brackets and other characters as far as I see.
  • If cursor is before the brackets when ci] is issued, then the results are as expected.

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 tracing the ci] command and its handling of cursor positions when the cursor is after the surrounding brackets. Reproduce the provided JavaScript example, then verify that clearing the brackets and entering insert mode also places the cursor inside them for all supported surrounding characters.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.