src/vs/workbench/contrib/snippets/browser/insertSnippet.ts/InsertSnippetAction/run
class InsertSnippetAction:	async run(accessor: ServicesAccessor, editor: ICodeEditor, arg: any): Promise<void> {
		const modeService = accessor.get(IModeService);
		const snippetService = accessor.get(ISnippetsService);

		if (!editor.hasModel()) {
			return;
		}

		const clipboardService = accessor.get(IClipboardService);
		const quickInputService = accessor.get(IQuickInputService);

		const snippet = await new Promise<Snippet | undefined>(async (resolve) => {

			const { lineNumber, column } = editor.getPosition();
			let { snippet, name, langId } = Args.fromUser(arg);

			if (snippet) {
				return resolve(new Snippet(
					[],
					'',
					'',
					'',
					snippet,
					'',
					SnippetSource.User,
				));
			}

			let languageId = LanguageId.Null;
			if (langId) {
				const otherLangId = modeService.getLanguageIdentifier(langId);
				if (otherLangId) {
					languageId = otherLangId.id;
				}
			} else {
				editor.getModel().tokenizeIfCheap(lineNumber);
				languageId = editor.getModel().getLanguageIdAtPosition(lineNumber, column);

				// validate the `languageId` to ensure this is a user
				// facing language with a name and the chance to have
				// snippets, else fall back to the outer language
				const otherLangId = modeService.getLanguageIdentifier(languageId);
				if (otherLangId && !modeService.getLanguageName(otherLangId.language)) {
					languageId = editor.getModel().getLanguageIdentifier().id;
				}
			}

			if (name) {
				// take selected snippet
				const snippet = (await snippetService.getSnippets(languageId, { includeNoPrefixSnippets: true })).find(snippet => snippet.name === name);
				resolve(snippet);

			} else {
				// let user pick a snippet
				const snippet = await this._pickSnippet(snippetService, quickInputService, languageId);
				resolve(snippet);
			}
		});

		if (!snippet) {
			return;
		}
		let clipboardText: string | undefined;
		if (snippet.needsClipboard) {
			clipboardText = await clipboardService.readText();
		}
		SnippetController2.get(editor).insert(snippet.codeSnippet, { clipboardText });
	}