MCPcopy Index your code
hub / github.com/philc/vimium / commandHandler

Method commandHandler

content_scripts/mode_visual.js:506–535  ·  view source on GitHub ↗
({ command: { command }, count })

Source from the content-addressed store, hash-verified

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();

Callers

nothing calls this directly

Calls 5

extendSelectionMethod · 0.95
runMovementMethod · 0.80
getDirectionMethod · 0.80
reverseSelectionMethod · 0.80
scrollIntoViewMethod · 0.80

Tested by

no test coverage detected