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

Method run

src/actions/operator.ts:665–708  ·  view source on GitHub ↗
(vimState: VimState, start: Position, end: Position)

Source from the content-addressed store, hash-verified

663 public modes = [Mode.Normal, Mode.Visual, Mode.VisualLine];
664
665 public async run(vimState: VimState, start: Position, end: Position): Promise<void> {
666 if (vimState.currentRegisterMode === RegisterMode.LineWise) {
667 start = start.getLineBegin();
668 end = end.getLineEnd();
669 } else if (vimState.currentMode === Mode.Visual && end.isLineEnd(vimState.document)) {
670 end = end.getRightThroughLineBreaks();
671 } else {
672 end = end.getRight();
673 }
674
675 const deleteRange = new vscode.Range(start, end);
676
677 Register.put(vimState, vimState.document.getText(deleteRange), this.multicursorIndex, true);
678
679 if (vimState.currentRegisterMode === RegisterMode.LineWise && configuration.autoindent) {
680 // Linewise is a bit of a special case - we want to preserve the first line's indentation,
681 // then let the language server adjust that indentation if it can.
682
683 const firstLineIndent = vimState.document.getText(
684 new vscode.Range(
685 deleteRange.start.getLineBegin(),
686 deleteRange.start.getLineBeginRespectingIndent(vimState.document),
687 ),
688 );
689
690 vimState.recordedState.transformer.replace(
691 deleteRange,
692 firstLineIndent,
693 PositionDiff.exactPosition(new Position(deleteRange.start.line, firstLineIndent.length)),
694 );
695
696 if (vimState.document.languageId !== 'plaintext') {
697 vimState.recordedState.transformer.vscodeCommand('editor.action.reindentselectedlines');
698 vimState.recordedState.transformer.moveCursor(
699 PositionDiff.endOfLine(),
700 this.multicursorIndex,
701 );
702 }
703 } else {
704 vimState.recordedState.transformer.delete(deleteRange);
705 }
706
707 await vimState.setCurrentMode(Mode.Insert);
708 }
709}
710
711@RegisterAction

Callers

nothing calls this directly

Calls 15

getLineBeginMethod · 0.80
getLineEndMethod · 0.80
isLineEndMethod · 0.80
getRightMethod · 0.80
putMethod · 0.80
getTextMethod · 0.80
exactPositionMethod · 0.80
vscodeCommandMethod · 0.80
moveCursorMethod · 0.80
endOfLineMethod · 0.80

Tested by

no test coverage detected