MCPcopy
hub / github.com/VSCodeVim/Vim / handleKeyEventLangmapped

Method handleKeyEventLangmapped

src/mode/modeHandler.ts:430–607  ·  view source on GitHub ↗
(key: string)

Source from the content-addressed store, hash-verified

428 }
429
430 private async handleKeyEventLangmapped(key: string): Promise<void> {
431 if (this.remapState.forceStopRecursiveRemapping) {
432 return;
433 }
434
435 const now = Date.now();
436
437 const printableKey = Notation.printableKey(key, configuration.leader);
438 Logger.debug(`Handling key: ${printableKey}`);
439
440 if (
441 // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
442 (key === SpecialKeys.TimeoutFinished ||
443 this.vimState.recordedState.bufferedKeys.length > 0) &&
444 this.vimState.recordedState.bufferedKeysTimeoutObj
445 ) {
446 // Handle the bufferedKeys or append the new key to the previously bufferedKeys
447 clearTimeout(this.vimState.recordedState.bufferedKeysTimeoutObj);
448 this.vimState.recordedState.bufferedKeysTimeoutObj = undefined;
449 this.vimState.recordedState.commandList = [...this.vimState.recordedState.bufferedKeys];
450 this.vimState.recordedState.bufferedKeys = [];
451 }
452
453 // rewrite copy
454 if (configuration.overrideCopy) {
455 // The conditions when you trigger a "copy" rather than a ctrl-c are
456 // too sophisticated to be covered by the "when" condition in package.json
457 if (key === '<D-c>') {
458 key = '<copy>';
459 }
460
461 if (key === '<C-c>' && process.platform !== 'darwin') {
462 if (!configuration.useCtrlKeys || isVisualMode(this.vimState.currentMode)) {
463 key = '<copy>';
464 }
465 }
466 }
467
468 // <C-d> triggers "add selection to next find match" by default,
469 // unless users explicity make <C-d>: true
470 // TODO: Destroy this silliness
471 if (key === '<C-d>' && !(configuration.handleKeys['<C-d>'] === true)) {
472 key = '<D-d>';
473 }
474
475 this.vimState.cursorsInitialState = this.vimState.cursors;
476 this.vimState.recordedState.commandList.push(key);
477
478 const oldMode = this.vimState.currentMode;
479 const oldFullMode = this.vimState.currentModeIncludingPseudoModes;
480 const oldStatusBarText = StatusBar.getText();
481 const oldWaitingForAnotherActionKey = this.vimState.recordedState.waitingForAnotherActionKey;
482
483 let handledAsRemap = false;
484 let handledAsAction = false;
485 try {
486 // Handling special case for '0'. From Vim documentation (:help :map-modes)
487 // Special case: While typing a count for a command in Normal mode, mapping zero

Callers 2

handleKeyEventMethod · 0.95

Calls 14

handleKeyAsAnActionMethod · 0.95
updateViewMethod · 0.95
isVisualModeFunction · 0.90
printableKeyMethod · 0.80
debugMethod · 0.80
getTextMethod · 0.80
displayErrorMethod · 0.80
fromVimErrorMethod · 0.80
updateShowCmdMethod · 0.80
resetCommandListMethod · 0.80
traceMethod · 0.80

Tested by

no test coverage detected