src/vs/editor/contrib/snippet/browser/snippetController2.ts/performSnippetEdits
export function performSnippetEdits(editor: ICodeEditor, edits: ISnippetEdit[]) {

	if (!editor.hasModel()) {
		return false;
	}
	if (edits.length === 0) {
		return false;
	}

	const model = editor.getModel();
	let newText = '';
	let last: ISnippetEdit | undefined;
	edits.sort((a, b) => Range.compareRangesUsingStarts(a.range, b.range));

	for (const item of edits) {
		if (last) {
			const between = Range.fromPositions(last.range.getEndPosition(), item.range.getStartPosition());
			const text = model.getValueInRange(between);
			newText += SnippetParser.escape(text);
		}
		newText += item.snippet;
		last = item;
	}

	const controller = SnippetController2.get(editor);
	if (!controller) {
		return false;
	}
	model.pushStackElement();
	const range = Range.plusRange(edits[0].range, edits[edits.length - 1].range);
	editor.setSelection(range);
	controller.insert(newText, { undoStopBefore: false });
	return controller.isInSnippet();
}