@@ -33,6 +33,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
33
33
import { IProgressService , ProgressLocation } from 'vs/platform/progress/common/progress' ;
34
34
import { IQuickInputService , IQuickPickItem } from 'vs/platform/quickinput/common/quickInput' ;
35
35
import { PostEditWidgetManager } from './postEditWidget' ;
36
+ import { MessageController } from 'vs/editor/contrib/message/browser/messageController' ;
36
37
37
38
export const changePasteTypeCommandId = 'editor.changePasteType' ;
38
39
@@ -212,6 +213,7 @@ export class CopyPasteController extends Disposable implements IEditorContributi
212
213
return ;
213
214
}
214
215
216
+ MessageController . get ( this . _editor ) ?. closeMessage ( ) ;
215
217
this . _currentPasteOperation ?. cancel ( ) ;
216
218
this . _currentPasteOperation = undefined ;
217
219
@@ -221,7 +223,10 @@ export class CopyPasteController extends Disposable implements IEditorContributi
221
223
return ;
222
224
}
223
225
224
- if ( ! this . isPasteAsEnabled ( ) ) {
226
+ if (
227
+ ! this . isPasteAsEnabled ( )
228
+ && ! this . _pasteAsActionContext // Still enable if paste as was explicitly requested
229
+ ) {
225
230
return ;
226
231
}
227
232
@@ -240,8 +245,19 @@ export class CopyPasteController extends Disposable implements IEditorContributi
240
245
241
246
const allProviders = this . _languageFeaturesService . documentPasteEditProvider
242
247
. ordered ( model )
243
- . filter ( provider => provider . pasteMimeTypes ?. some ( type => matchesMimeType ( type , allPotentialMimeTypes ) ) ) ;
248
+ . filter ( provider => {
249
+ if ( this . _pasteAsActionContext ?. preferredId ) {
250
+ if ( this . _pasteAsActionContext . preferredId !== provider . id ) {
251
+ return false ;
252
+ }
253
+ }
254
+
255
+ return provider . pasteMimeTypes ?. some ( type => matchesMimeType ( type , allPotentialMimeTypes ) ) ;
256
+ } ) ;
244
257
if ( ! allProviders . length ) {
258
+ if ( this . _pasteAsActionContext ?. preferredId ) {
259
+ this . showPasteAsNoEditMessage ( selections , this . _pasteAsActionContext ?. preferredId ) ;
260
+ }
245
261
return ;
246
262
}
247
263
@@ -258,6 +274,10 @@ export class CopyPasteController extends Disposable implements IEditorContributi
258
274
}
259
275
}
260
276
277
+ private showPasteAsNoEditMessage ( selections : readonly Selection [ ] , editId : string ) {
278
+ MessageController . get ( this . _editor ) ?. showMessage ( localize ( 'pasteAsError' , "No paste edits for '{0}' found" , editId ) , selections [ 0 ] . getStartPosition ( ) ) ;
279
+ }
280
+
261
281
private doPasteInline ( allProviders : readonly DocumentPasteEditProvider [ ] , selections : readonly Selection [ ] , dataTransfer : VSDataTransfer , metadata : CopyMetadata | undefined , context : DocumentPasteContext ) : void {
262
282
const p = createCancelablePromise ( async ( token ) => {
263
283
const editor = this . _editor ;
@@ -339,6 +359,9 @@ export class CopyPasteController extends Disposable implements IEditorContributi
339
359
}
340
360
341
361
if ( ! providerEdits . length ) {
362
+ if ( context . only ) {
363
+ this . showPasteAsNoEditMessage ( selections , context . only ) ;
364
+ }
342
365
return ;
343
366
}
344
367
0 commit comments