src/vs/workbench/api/browser/mainThreadEditor.ts/MainThreadTextEditor/insertSnippet
class MainThreadTextEditor:	async insertSnippet(modelVersionId: number, template: string, ranges: readonly IRange[], opts: IUndoStopOptions) {

		if (!this._codeEditor || !this._codeEditor.hasModel()) {
			return false;
		}

		// check if clipboard is required and only iff read it (async)
		let clipboardText: string | undefined;
		const needsTemplate = SnippetParser.guessNeedsClipboard(template);
		if (needsTemplate) {
			const state = new EditorState(this._codeEditor, CodeEditorStateFlag.Value | CodeEditorStateFlag.Position);
			clipboardText = await this._clipboardService.readText();
			if (!state.validate(this._codeEditor)) {
				return false;
			}
		}

		if (this._codeEditor.getModel().getVersionId() !== modelVersionId) {
			// ignored because emmet tests fail...
			// return false;
		}

		const snippetController = SnippetController2.get(this._codeEditor);
		if (!snippetController) {
			return false;
		}

		// cancel previous snippet mode
		// snippetController.leaveSnippet();

		// set selection, focus editor
		const selections = ranges.map(r => new Selection(r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn));
		this._codeEditor.setSelections(selections);
		this._codeEditor.focus();

		// make modifications
		snippetController.insert(template, {
			overwriteBefore: 0, overwriteAfter: 0,
			undoStopBefore: opts.undoStopBefore, undoStopAfter: opts.undoStopAfter,
			clipboardText
		});

		return true;
	}