()
| 416 | }; |
| 417 | |
| 418 | const p2 = () => { |
| 419 | return new Promise<ResultType | undefined>((p2Resolve, p2Reject) => { |
| 420 | if (waitsForTimeout) { |
| 421 | setTimeout(async () => { |
| 422 | if (modeHandler.remapState.isCurrentlyPerformingRemapping) { |
| 423 | // Performing a remapping, which means it started at the right time but it has not |
| 424 | // finished yet (maybe the remapping has a lot of keys to handle) so we wait for the |
| 425 | // remapping to finish |
| 426 | const wait = (ms: number) => new Promise((res) => setTimeout(res, ms)); |
| 427 | while (modeHandler.remapState.isCurrentlyPerformingRemapping) { |
| 428 | // Wait a little bit longer here because the currently performing remap might have |
| 429 | // some remaining keys to handle after it finishes performing the remap and there |
| 430 | // might even be there some keys still to be sent that might create another remap. |
| 431 | // Example: if you have and ambiguous remap like 'ab -> abcd' and 'abc -> abcdef' |
| 432 | // and an insert remap like 'jj -> <Esc>' and you press 'abjj' the first 'j' breaks |
| 433 | // the ambiguity and makes the remap start performing, but when the remap finishes |
| 434 | // performing there is still the 'jj' to be handled and remapped. |
| 435 | await wait(10); |
| 436 | } |
| 437 | } |
| 438 | // Get lines, position and mode after timeout + offset finishes |
| 439 | p2Resolve({ |
| 440 | lines: modeHandler.vimState.document.getText(), |
| 441 | position: modeHandler.vimState.editor.selection.start, |
| 442 | endMode: modeHandler.vimState.currentMode, |
| 443 | }); |
| 444 | }, timeout + timeoutOffset); |
| 445 | } else { |
| 446 | p2Resolve(undefined); |
| 447 | } |
| 448 | }); |
| 449 | }; |
| 450 | |
| 451 | // Assumes key presses are single characters for now |
| 452 | await modeHandler.handleMultipleKeyEvents(tokenizeKeySequence(step.keysPressed), false); |
no test coverage detected