(vimState: VimState, start: Position, end: Position)
| 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 |
nothing calls this directly
no test coverage detected