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

Function testItWithRemaps

test/testSimplifier.ts:334–525  ·  view source on GitHub ↗
(testObj: ITestWithRemapsObject)

Source from the content-addressed store, hash-verified

332}
333
334async function testItWithRemaps(testObj: ITestWithRemapsObject): Promise<ModeHandler> {
335 const editor = vscode.window.activeTextEditor;
336 assert(editor, 'Expected an active editor');
337
338 await applyDocState(editor, DocState.parse(testObj.start));
339
340 // Generate a brand new ModeHandler for this editor
341 ModeHandlerMap.clear();
342 const [modeHandler, _] = await ModeHandlerMap.getOrCreate(editor);
343
344 const config = Globals.mockConfiguration;
345
346 // Change remappings
347 if (testObj.remaps) {
348 if (!(testObj.remaps instanceof Array)) {
349 config.normalModeKeyBindings = testObj.remaps?.normalModeKeyBindings ?? [];
350 config.normalModeKeyBindingsNonRecursive =
351 testObj.remaps?.normalModeKeyBindingsNonRecursive ?? [];
352 config.insertModeKeyBindings = testObj.remaps?.insertModeKeyBindings ?? [];
353 config.insertModeKeyBindingsNonRecursive =
354 testObj.remaps?.insertModeKeyBindingsNonRecursive ?? [];
355 config.visualModeKeyBindings = testObj.remaps?.visualModeKeyBindings ?? [];
356 config.visualModeKeyBindingsNonRecursive =
357 testObj.remaps?.visualModeKeyBindingsNonRecursive ?? [];
358 config.operatorPendingModeKeyBindings = testObj.remaps?.operatorPendingModeKeyBindings ?? [];
359 config.operatorPendingModeKeyBindingsNonRecursive =
360 testObj.remaps?.operatorPendingModeKeyBindingsNonRecursive ?? [];
361 } else {
362 await parseVimRCMappings(testObj.remaps);
363 }
364 }
365
366 const timeout = config.timeout;
367 const timeoutOffset = timeout / 2;
368
369 await reloadConfiguration(config);
370
371 for (const [index, step] of testObj.steps.entries()) {
372 const resolvedStep = (() => {
373 let start: DocState;
374 if (index === 0) {
375 start = DocState.parse(testObj.start);
376 } else {
377 const prevStepResult = testObj.steps[index - 1].stepResult;
378 start = DocState.parse(prevStepResult.endAfterTimeout ?? prevStepResult.end);
379 }
380
381 const stepResult = testObj.steps[index].stepResult;
382 return {
383 start,
384 end: DocState.parse(stepResult.end),
385 endAfterTimeout: stepResult.endAfterTimeout
386 ? DocState.parse(stepResult.endAfterTimeout)
387 : undefined,
388 };
389 })();
390
391 const stepTitleOrIndex = step.title ? `nr. ${index} - "${step.title}"` : index;

Callers

nothing calls this directly

Calls 13

reloadConfigurationFunction · 0.90
applyDocStateFunction · 0.85
parseVimRCMappingsFunction · 0.85
tokenizeKeySequenceFunction · 0.85
p1Function · 0.85
p2Function · 0.85
getOrCreateMethod · 0.80
entriesMethod · 0.80
clearJumpsMethod · 0.80
joinMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected