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

Function getAndUpdateModeHandler

extensionBase.ts:30–69  ·  view source on GitHub ↗
(
  forceSyncAndUpdate = false,
)

Source from the content-addressed store, hash-verified

28}
29
30export async function getAndUpdateModeHandler(
31 forceSyncAndUpdate = false,
32): Promise<ModeHandler | undefined> {
33 const activeTextEditor = vscode.window.activeTextEditor;
34 if (activeTextEditor === undefined || activeTextEditor.document.isClosed) {
35 return undefined;
36 }
37
38 const [curHandler, isNew] = await ModeHandlerMap.getOrCreate(activeTextEditor);
39 if (isNew) {
40 extensionContext.subscriptions.push(curHandler);
41 }
42
43 curHandler.vimState.editor = activeTextEditor;
44
45 if (
46 forceSyncAndUpdate ||
47 !previousActiveEditorUri ||
48 previousActiveEditorUri !== activeTextEditor.document.uri
49 ) {
50 // We sync the cursors here because ModeHandler is specific to a document, not an editor, so we
51 // need to update our representation of the cursors when switching between editors for the same document.
52 // This will be unnecessary once #4889 is fixed.
53 curHandler.syncCursors();
54 curHandler.updateView({ drawSelection: false, revealRange: false });
55 }
56
57 previousActiveEditorUri = activeTextEditor.document.uri;
58
59 if (curHandler.focusChanged) {
60 curHandler.focusChanged = false;
61
62 if (previousActiveEditorUri) {
63 const prevHandler = ModeHandlerMap.get(previousActiveEditorUri);
64 prevHandler!.focusChanged = true;
65 }
66 }
67
68 return curHandler;
69}
70
71/**
72 * Loads and validates the user's configuration

Callers 15

marks.test.tsFile · 0.90
jumpToNewFileFunction · 0.90
insertLine.test.tsFile · 0.90
modeVisual.test.tsFile · 0.90
modeNormal.test.tsFile · 0.90
modeInsert.test.tsFile · 0.90
register.test.tsFile · 0.90

Calls 4

getOrCreateMethod · 0.80
syncCursorsMethod · 0.80
updateViewMethod · 0.65
getMethod · 0.65

Tested by 2

jumpToNewFileFunction · 0.72
setupWithBindingsFunction · 0.72