({ command: { command }, count })
| 504 | } |
| 505 | |
| 506 | commandHandler({ command: { command }, count }) { |
| 507 | if (count == null) count = 1; |
| 508 | switch (typeof command) { |
| 509 | case "string": |
| 510 | for (let i = 0, end = count; i < end; i++) { |
| 511 | this.movement.runMovement(command); |
| 512 | // If the current selection |
| 513 | // * has only 1 line (the line that is selected when we # enter the visual line mode), and |
| 514 | // * its direction is different from the command, |
| 515 | // then the command will in effect unselect that line. In this case, we restore that line |
| 516 | // and reverse its direction, keeping that line selected. |
| 517 | if (this.selection.isCollapsed) { |
| 518 | this.extendSelection(); |
| 519 | const [direction, granularity] = command.split(" "); |
| 520 | if ((this.movement.getDirection() !== direction) && (granularity === "line")) { |
| 521 | this.movement.reverseSelection(); |
| 522 | } |
| 523 | this.movement.runMovement(command); |
| 524 | } |
| 525 | } |
| 526 | break; |
| 527 | case "function": |
| 528 | command(count); |
| 529 | break; |
| 530 | } |
| 531 | this.movement.scrollIntoView(); |
| 532 | if (this.modeIsActive) { |
| 533 | return this.extendSelection(); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | extendSelection() { |
| 538 | const initialDirection = this.movement.getDirection(); |
nothing calls this directly
no test coverage detected