(
args: { drawSelection: boolean; revealRange: boolean } = {
drawSelection: true,
revealRange: true,
},
)
| 1286 | } |
| 1287 | |
| 1288 | public updateView( |
| 1289 | args: { drawSelection: boolean; revealRange: boolean } = { |
| 1290 | drawSelection: true, |
| 1291 | revealRange: true, |
| 1292 | }, |
| 1293 | ): void { |
| 1294 | // Draw selection (or cursor) |
| 1295 | if (args.drawSelection) { |
| 1296 | let selectionMode: Mode = this.vimState.currentMode; |
| 1297 | if (this.vimState.modeData.mode === Mode.SearchInProgressMode) { |
| 1298 | selectionMode = this.vimState.modeData.commandLine.previousMode; |
| 1299 | } else if (this.vimState.modeData.mode === Mode.CommandlineInProgress) { |
| 1300 | selectionMode = this.vimState.modeData.commandLine.previousMode; |
| 1301 | } else if (this.vimState.modeData.mode === Mode.SurroundInputMode) { |
| 1302 | selectionMode = this.vimState.surround!.previousMode; |
| 1303 | } |
| 1304 | |
| 1305 | let selections: vscode.Selection[] = []; |
| 1306 | for (const cursor of this.vimState.cursors) { |
| 1307 | let { start, stop } = cursor; |
| 1308 | switch (selectionMode) { |
| 1309 | case Mode.Visual: |
| 1310 | /** |
| 1311 | * Always select the letter that we started visual mode on, no matter |
| 1312 | * if we are in front or behind it. Imagine that we started visual mode |
| 1313 | * with some text like this: |
| 1314 | * |
| 1315 | * abc|def |
| 1316 | * |
| 1317 | * (The | represents the cursor.) If we now press w, we'll select def, |
| 1318 | * but if we hit b we expect to select abcd, so we need to getRight() on the |
| 1319 | * start of the selection when it precedes where we started visual mode. |
| 1320 | */ |
| 1321 | if (start.isAfterOrEqual(stop)) { |
| 1322 | start = start.getRight(); |
| 1323 | } |
| 1324 | |
| 1325 | selections.push(new vscode.Selection(start, stop)); |
| 1326 | break; |
| 1327 | |
| 1328 | case Mode.VisualLine: |
| 1329 | if (start.isBeforeOrEqual(stop)) { |
| 1330 | selections.push(new vscode.Selection(start.getLineBegin(), stop.getLineEnd())); |
| 1331 | } else { |
| 1332 | selections.push(new vscode.Selection(start.getLineEnd(), stop.getLineBegin())); |
| 1333 | } |
| 1334 | break; |
| 1335 | |
| 1336 | case Mode.VisualBlock: |
| 1337 | for (const line of TextEditor.iterateLinesInBlock(this.vimState, cursor)) { |
| 1338 | selections.push( |
| 1339 | new vscode.Selection( |
| 1340 | this.vimState.document.validatePosition(line.start), |
| 1341 | this.vimState.document.validatePosition(line.end), |
| 1342 | ), |
| 1343 | ); |
| 1344 | } |
| 1345 | break; |
no test coverage detected