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

Method execAction

src/textobject/textobject.ts:522–560  ·  view source on GitHub ↗
(position: Position, vimState: VimState)

Source from the content-addressed store, hash-verified

520 keys = ['i', 'p'];
521
522 public async execAction(position: Position, vimState: VimState): Promise<IMovement> {
523 vimState.currentRegisterMode = RegisterMode.LineWise;
524
525 let start: Position;
526 let stop: Position;
527
528 if (vimState.document.lineAt(position).isEmptyOrWhitespace) {
529 // The cursor is at an empty line, so white lines are the paragraph.
530 start = position.getLineBegin();
531 stop = position.getLineEnd();
532 while (start.line > 0 && vimState.document.lineAt(start.getUp()).isEmptyOrWhitespace) {
533 start = start.getUp();
534 }
535 while (
536 stop.line < vimState.document.lineCount - 1 &&
537 vimState.document.lineAt(stop.getDown()).isEmptyOrWhitespace
538 ) {
539 stop = stop.with({ character: 0 }).getDown();
540 }
541 } else {
542 const currentParagraphBegin = getCurrentParagraphBeginning(position, true);
543 stop = getCurrentParagraphEnd(position, true);
544 if (vimState.document.lineAt(currentParagraphBegin).isEmptyOrWhitespace) {
545 start = currentParagraphBegin.getRightThroughLineBreaks();
546 } else {
547 start = currentParagraphBegin;
548 }
549
550 // Exclude additional blank lines.
551 while (stop.line > 0 && vimState.document.lineAt(stop).isEmptyOrWhitespace) {
552 stop = stop.getUp().getLineEnd();
553 }
554 }
555
556 return {
557 start,
558 stop,
559 };
560 }
561}
562
563@RegisterAction

Callers

nothing calls this directly

Calls 7

getCurrentParagraphEndFunction · 0.90
getLineBeginMethod · 0.80
getLineEndMethod · 0.80
getUpMethod · 0.80
getDownMethod · 0.80

Tested by

no test coverage detected