MCPcopy
hub / github.com/VSCodeVim/Vim / execActionForOperator

Method execActionForOperator

src/actions/motion.ts:1463–1492  ·  view source on GitHub ↗
(
    position: Position,
    vimState: VimState,
    firstIteration: boolean,
    lastIteration: boolean,
  )

Source from the content-addressed store, hash-verified

1461 }
1462
1463 public override async execActionForOperator(
1464 position: Position,
1465 vimState: VimState,
1466 firstIteration: boolean,
1467 lastIteration: boolean,
1468 ): Promise<Position> {
1469 const result = await this.execAction(position, vimState, firstIteration, lastIteration);
1470
1471 /*
1472 From the Vim documentation:
1473
1474 Another special case: When using the "w" motion in combination with an
1475 operator and the last word moved over is at the end of a line, the end of
1476 that word becomes the end of the operated text, not the first word in the
1477 next line.
1478 */
1479
1480 if (
1481 result.line > position.line + 1 ||
1482 (result.line === position.line + 1 && result.isFirstWordOfLine(vimState.document))
1483 ) {
1484 return position.getLineEnd();
1485 }
1486
1487 if (result.isLineEnd(vimState.document)) {
1488 return new Position(result.line, result.character + 1);
1489 }
1490
1491 return result;
1492 }
1493}
1494
1495@RegisterAction

Callers

nothing calls this directly

Calls 4

execActionMethod · 0.95
isFirstWordOfLineMethod · 0.80
getLineEndMethod · 0.80
isLineEndMethod · 0.80

Tested by

no test coverage detected