(vimState: VimState, start: Position, end: Position)
| 207 | override createsUndoPoint = false; |
| 208 | |
| 209 | public async run(vimState: VimState, start: Position, end: Position): Promise<void> { |
| 210 | [start, end] = sorted(start, end); |
| 211 | let extendedEnd = new Position(end.line, end.character + 1); |
| 212 | |
| 213 | if (vimState.currentRegisterMode === RegisterMode.LineWise) { |
| 214 | start = start.getLineBegin(); |
| 215 | extendedEnd = extendedEnd.getLineEnd(); |
| 216 | } |
| 217 | |
| 218 | const sLine = vimState.document.lineAt(start.line).text; |
| 219 | const eLine = vimState.document.lineAt(extendedEnd.line).text; |
| 220 | if ( |
| 221 | start.character !== 0 && |
| 222 | isLowSurrogate(sLine.charCodeAt(start.character)) && |
| 223 | isHighSurrogate(sLine.charCodeAt(start.character - 1)) |
| 224 | ) { |
| 225 | start = start.getLeft(); |
| 226 | } |
| 227 | if ( |
| 228 | extendedEnd.character !== 0 && |
| 229 | isLowSurrogate(eLine.charCodeAt(extendedEnd.character)) && |
| 230 | isHighSurrogate(eLine.charCodeAt(extendedEnd.character - 1)) |
| 231 | ) { |
| 232 | extendedEnd = extendedEnd.getRight(); |
| 233 | } |
| 234 | const range = new vscode.Range(start, extendedEnd); |
| 235 | let text = vimState.document.getText(range); |
| 236 | |
| 237 | // If we selected the newline character, add it as well. |
| 238 | if ( |
| 239 | vimState.currentMode === Mode.Visual && |
| 240 | extendedEnd.character === vimState.document.lineAt(extendedEnd).text.length + 1 |
| 241 | ) { |
| 242 | text = text + '\n'; |
| 243 | } |
| 244 | |
| 245 | this.highlightYankedRanges(vimState, [range]); |
| 246 | |
| 247 | Register.put(vimState, text, this.multicursorIndex, true); |
| 248 | |
| 249 | vimState.cursorStopPosition = |
| 250 | vimState.currentMode === Mode.Normal && vimState.currentRegisterMode === RegisterMode.LineWise |
| 251 | ? start.with({ character: vimState.cursorStopPosition.character }) |
| 252 | : start; |
| 253 | |
| 254 | await vimState.setCurrentMode(Mode.Normal); |
| 255 | |
| 256 | const numLinesYanked = text.split('\n').length; |
| 257 | reportLinesYanked(numLinesYanked, vimState); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | @RegisterAction |
nothing calls this directly
no test coverage detected