From fec4c8e5bbfeca9c856017c4a9c714f3d69ab4f7 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Tue, 12 Dec 2023 11:39:31 -0800 Subject: [PATCH] Fix types on `CopyPasteController.get` (#200600) Fixes #200597 --- src/vs/editor/contrib/clipboard/browser/clipboard.ts | 2 +- .../contrib/dropOrPasteInto/browser/copyPasteController.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vs/editor/contrib/clipboard/browser/clipboard.ts b/src/vs/editor/contrib/clipboard/browser/clipboard.ts index 08a834a6655..8ca27d4fbae 100644 --- a/src/vs/editor/contrib/clipboard/browser/clipboard.ts +++ b/src/vs/editor/contrib/clipboard/browser/clipboard.ts @@ -229,7 +229,7 @@ if (PasteAction) { if (focusedEditor && focusedEditor.hasTextFocus()) { const result = focusedEditor.getContainerDomNode().ownerDocument.execCommand('paste'); if (result) { - return CopyPasteController.get(focusedEditor).finishedPaste(); + return CopyPasteController.get(focusedEditor)?.finishedPaste() ?? Promise.resolve(); } else if (platform.isWeb) { // Use the clipboard service if document.execCommand('paste') was not successful return (async () => { diff --git a/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.ts b/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.ts index eba9b5f0f43..59281b6154e 100644 --- a/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.ts +++ b/src/vs/editor/contrib/dropOrPasteInto/browser/copyPasteController.ts @@ -51,8 +51,8 @@ export class CopyPasteController extends Disposable implements IEditorContributi public static readonly ID = 'editor.contrib.copyPasteActionController'; - public static get(editor: ICodeEditor): CopyPasteController { - return editor.getContribution(CopyPasteController.ID)!; + public static get(editor: ICodeEditor): CopyPasteController | null { + return editor.getContribution(CopyPasteController.ID); } private readonly _editor: ICodeEditor;