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

Method getOrCreate

src/mode/modeHandlerMap.ts:10–22  ·  view source on GitHub ↗
(editor: TextEditor)

Source from the content-addressed store, hash-verified

8 private modeHandlerMap = new Map<Uri, ModeHandler>();
9
10 public async getOrCreate(editor: TextEditor): Promise<[ModeHandler, boolean]> {
11 const editorId = editor.document.uri;
12
13 let isNew = false;
14 let modeHandler: ModeHandler | undefined = this.get(editorId);
15
16 if (!modeHandler) {
17 isNew = true;
18 modeHandler = await ModeHandler.create(this, editor);
19 this.modeHandlerMap.set(editorId, modeHandler);
20 }
21 return [modeHandler, isNew];
22 }
23
24 public get(uri: Uri): ModeHandler | undefined {
25 return this.modeHandlerMap.get(uri);

Callers 4

getAndUpdateModeHandlerFunction · 0.80
testItFunction · 0.80
testItWithRemapsFunction · 0.80

Calls 2

getMethod · 0.95
createMethod · 0.80

Tested by

no test coverage detected