src/vs/editor/contrib/copyPaste/browser/copyPasteController.ts/CopyPasteController/handlePaste
class CopyPasteController:	private async handlePaste(e: ClipboardEvent) {
		if (!e.clipboardData || !this._editor.hasTextFocus()) {
			return;
		}

		const selections = this._editor.getSelections();
		if (!selections?.length || !this._editor.hasModel()) {
			return;
		}

		const model = this._editor.getModel();
		if (!this.arePasteActionsEnabled(model)) {
			return;
		}

		let metadata: CopyMetadata | undefined;
		const rawMetadata = e.clipboardData?.getData(vscodeClipboardMime);
		if (rawMetadata && typeof rawMetadata === 'string') {
			metadata = JSON.parse(rawMetadata);
		}

		const providers = this._languageFeaturesService.documentPasteEditProvider.ordered(model);
		if (!providers.length) {
			return;
		}

		e.preventDefault();
		e.stopImmediatePropagation();

		const originalDocVersion = model.getVersionId();
		const tokenSource = new EditorStateCancellationTokenSource(this._editor, CodeEditorStateFlag.Value | CodeEditorStateFlag.Selection);

		try {
			const dataTransfer = toVSDataTransfer(e.clipboardData);

			if (metadata?.id && this._currentClipboardItem?.handle === metadata.id) {
				const toMergeDataTransfer = await this._currentClipboardItem.dataTransferPromise;
				toMergeDataTransfer.forEach((value, key) => {
					dataTransfer.replace(key, value);
				});
			}

			if (!dataTransfer.has(Mimes.uriList)) {
				const resources = await this._clipboardService.readResources();
				if (resources.length) {
					dataTransfer.append(Mimes.uriList, createStringDataTransferItem(UriList.create(resources)));
				}
			}

			dataTransfer.delete(vscodeClipboardMime);

			for (const provider of providers) {
				if (!provider.pasteMimeTypes.some(type => {
					if (type.toLowerCase() === DataTransfers.FILES.toLowerCase()) {
						return [...dataTransfer.values()].some(item => item.asFile());
					}
					return dataTransfer.has(type);
				})) {
					continue;
				}

				const edit = await provider.provideDocumentPasteEdits(model, selections, dataTransfer, tokenSource.token);
				if (originalDocVersion !== model.getVersionId()) {
					return;
				}

				if (edit) {
					performSnippetEdit(this._editor, typeof edit.insertText === 'string' ? SnippetParser.escape(edit.insertText) : edit.insertText.snippet, selections);

					if (edit.additionalEdit) {
						await this._bulkEditService.apply(ResourceEdit.convert(edit.additionalEdit), { editor: this._editor });
					}
					return;
				}
			}

			// Default handler
			const textDataTransfer = dataTransfer.get(Mimes.text) ?? dataTransfer.get('text');
			if (!textDataTransfer) {
				return;
			}

			const text = await textDataTransfer.asString();
			if (originalDocVersion !== model.getVersionId()) {
				return;
			}

			this._editor.trigger('keyboard', Handler.Paste, <PastePayload>{
				text: text,
				pasteOnNewLine: metadata?.wasFromEmptySelection,
				multicursorText: null
			});
		} finally {
			tokenSource.dispose();
		}
	}