Vim icon indicating copy to clipboard operation
Vim copied to clipboard

vit operation error selected character >

Open lfire opened this issue 1 year ago • 3 comments

Describe the bug The selected character was error, when press vit in normal mode.As shown below:

image

The lower part of the figure shows how it looks in vim, which is correct.

To Reproduce Steps to reproduce the behavior:

  1. get a vue file with code like:
        <li
          v-for="item in diseases"
          :key="item.name"
          class="ellipsis"
          aria-role="button"
          :aria-label="item.name"
          @click="toDisease(item)"
        >
          {{ item.name }}
          <span class="btn-link" />
        </li>
  1. move cursor into li tag
  2. presse vit on normal mode
  • Extension (VsCodeVim) version: v1.27.3
  • VSCode version: 1.91.1 (Universal)
  • OS: Darwin arm64 23.5.0

commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729 date: 2024-07-09T22:07:54.982Z Electron: 29.4.0 ElectronBuildId: 9728852 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0

Additional context Add any other context about the problem here.

lfire avatar Jul 16 '24 14:07 lfire

And vat operation cannot select span tags

lfire avatar Jul 16 '24 15:07 lfire

I think it's probably caused by the code here: L998

https://github.com/VSCodeVim/Vim/blob/e3993621a1eda03678a2b116e893f3810d0d5f06/src/mode/modeHandler.ts#L990-L1002

The meaning of this code is that if the starting position is chosen as the end of the line, it needs to be moved one character to the left

So we will select the '>' option in the start tag

I feel like there's no problem with the handling here, after all, Vim's cursor is on the character, so it can't appear at the end of the line, only on the last character

HenryTSZ avatar Jul 19 '24 07:07 HenryTSZ

@J-Fields

Can we use the built-in functionality of VSCode for tag manipulation?

https://github.com/VSCodeVim/Vim/blob/e3993621a1eda03678a2b116e893f3810d0d5f06/src/actions/motion.ts#L2303-L2343

I will replace the code above with the code below

abstract class MoveTagMatch extends ExpandingSelection {
  override modes = [Mode.Normal, Mode.Visual, Mode.VisualBlock];
  protected includeTag = false;
  override isJump = true;

  public override async execAction(position: Position, vimState: VimState): Promise<IMovement> {
    await vscode.commands.executeCommand('editor.emmet.action.balanceIn');
    const selection = vimState.editor.selection;
    return { start: selection.start, stop: selection.end };
  }
}

The selection range here is correct, but after executing the code to correct the cursor position, the range is incorrect again

So is there any way we can avoid executing the subsequent correction code? I think we just need to execute it up to this point, and then we just need to execute v/c/d/y

PS: Including this bug #8872, I think the same solution can also be used

HenryTSZ avatar Jul 19 '24 07:07 HenryTSZ

Same problem here 👀

titouandk avatar Jan 04 '25 22:01 titouandk