@@ -1300,23 +1300,7 @@ class CompletionsAdapter {
1300
1300
}
1301
1301
}
1302
1302
1303
- class InlineCompletionAdapterBase {
1304
- async provideInlineCompletions ( resource : URI , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1305
- return undefined ;
1306
- }
1307
-
1308
- async provideInlineEditsForRange ( resource : URI , range : IRange , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1309
- return undefined ;
1310
- }
1311
-
1312
- disposeCompletions ( pid : number ) : void { }
1313
-
1314
- handleDidShowCompletionItem ( pid : number , idx : number , updatedInsertText : string ) : void { }
1315
-
1316
- handlePartialAccept ( pid : number , idx : number , acceptedCharacters : number , info : languages . PartialAcceptInfo ) : void { }
1317
- }
1318
-
1319
- class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1303
+ class InlineCompletionAdapter {
1320
1304
private readonly _references = new ReferenceMap < {
1321
1305
dispose ( ) : void ;
1322
1306
items : readonly vscode . InlineCompletionItem [ ] ;
@@ -1330,21 +1314,22 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1330
1314
private readonly _provider : vscode . InlineCompletionItemProvider ,
1331
1315
private readonly _commands : CommandsConverter ,
1332
1316
) {
1333
- super ( ) ;
1334
1317
}
1335
1318
1336
1319
public get supportsHandleEvents ( ) : boolean {
1337
1320
return isProposedApiEnabled ( this . _extension , 'inlineCompletionsAdditions' )
1338
1321
&& ( typeof this . _provider . handleDidShowCompletionItem === 'function'
1339
- || typeof this . _provider . handleDidPartiallyAcceptCompletionItem === 'function' ) ;
1322
+ || typeof this . _provider . handleDidPartiallyAcceptCompletionItem === 'function'
1323
+ || typeof this . _provider . handleDidRejectCompletionItem === 'function'
1324
+ ) ;
1340
1325
}
1341
1326
1342
1327
private readonly languageTriggerKindToVSCodeTriggerKind : Record < languages . InlineCompletionTriggerKind , InlineCompletionTriggerKind > = {
1343
1328
[ languages . InlineCompletionTriggerKind . Automatic ] : InlineCompletionTriggerKind . Automatic ,
1344
1329
[ languages . InlineCompletionTriggerKind . Explicit ] : InlineCompletionTriggerKind . Invoke ,
1345
1330
} ;
1346
1331
1347
- override async provideInlineCompletions ( resource : URI , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1332
+ async provideInlineCompletions ( resource : URI , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1348
1333
const doc = this . _documents . getDocument ( resource ) ;
1349
1334
const pos = typeConvert . Position . to ( position ) ;
1350
1335
@@ -1407,6 +1392,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1407
1392
insertText : typeof insertText === 'string' ? insertText : { snippet : insertText . value } ,
1408
1393
filterText : item . filterText ,
1409
1394
range : item . range ? typeConvert . Range . from ( item . range ) : undefined ,
1395
+ showRange : ( this . _isAdditionsProposedApiEnabled && item . showRange ) ? typeConvert . Range . from ( item . showRange ) : undefined ,
1410
1396
command,
1411
1397
action,
1412
1398
idx : idx ,
@@ -1430,7 +1416,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1430
1416
} ;
1431
1417
}
1432
1418
1433
- override async provideInlineEditsForRange ( resource : URI , range : IRange , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1419
+ async provideInlineEditsForRange ( resource : URI , range : IRange , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
1434
1420
if ( ! this . _provider . provideInlineEditsForRange ) {
1435
1421
return undefined ;
1436
1422
}
@@ -1516,12 +1502,12 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1516
1502
} ;
1517
1503
}
1518
1504
1519
- override disposeCompletions ( pid : number ) {
1505
+ disposeCompletions ( pid : number ) {
1520
1506
const data = this . _references . disposeReferenceId ( pid ) ;
1521
1507
data ?. dispose ( ) ;
1522
1508
}
1523
1509
1524
- override handleDidShowCompletionItem ( pid : number , idx : number , updatedInsertText : string ) : void {
1510
+ handleDidShowCompletionItem ( pid : number , idx : number , updatedInsertText : string ) : void {
1525
1511
const completionItem = this . _references . get ( pid ) ?. items [ idx ] ;
1526
1512
if ( completionItem ) {
1527
1513
if ( this . _provider . handleDidShowCompletionItem && this . _isAdditionsProposedApiEnabled ) {
@@ -1530,7 +1516,7 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1530
1516
}
1531
1517
}
1532
1518
1533
- override handlePartialAccept ( pid : number , idx : number , acceptedCharacters : number , info : languages . PartialAcceptInfo ) : void {
1519
+ handlePartialAccept ( pid : number , idx : number , acceptedCharacters : number , info : languages . PartialAcceptInfo ) : void {
1534
1520
const completionItem = this . _references . get ( pid ) ?. items [ idx ] ;
1535
1521
if ( completionItem ) {
1536
1522
if ( this . _provider . handleDidPartiallyAcceptCompletionItem && this . _isAdditionsProposedApiEnabled ) {
@@ -1539,6 +1525,15 @@ class InlineCompletionAdapter extends InlineCompletionAdapterBase {
1539
1525
}
1540
1526
}
1541
1527
}
1528
+
1529
+ handleRejection ( pid : number , idx : number ) : void {
1530
+ const completionItem = this . _references . get ( pid ) ?. items [ idx ] ;
1531
+ if ( completionItem ) {
1532
+ if ( this . _provider . handleDidRejectCompletionItem && this . _isAdditionsProposedApiEnabled ) {
1533
+ this . _provider . handleDidRejectCompletionItem ( completionItem ) ;
1534
+ }
1535
+ }
1536
+ }
1542
1537
}
1543
1538
1544
1539
class InlineEditAdapter {
@@ -2677,38 +2672,51 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
2677
2672
this . _withAdapter ( handle , CompletionsAdapter , adapter => adapter . releaseCompletionItems ( id ) , undefined , undefined ) ;
2678
2673
}
2679
2674
2680
- // --- ghost test
2675
+ // --- ghost text
2681
2676
2682
2677
registerInlineCompletionsProvider ( extension : IExtensionDescription , selector : vscode . DocumentSelector , provider : vscode . InlineCompletionItemProvider , metadata : vscode . InlineCompletionItemProviderMetadata | undefined ) : vscode . Disposable {
2683
2678
const adapter = new InlineCompletionAdapter ( extension , this . _documents , provider , this . _commands . converter ) ;
2684
2679
const handle = this . _addNewAdapter ( adapter , extension ) ;
2685
- this . _proxy . $registerInlineCompletionsSupport ( handle , this . _transformDocumentSelector ( selector , extension ) , adapter . supportsHandleEvents ,
2686
- ExtensionIdentifier . toKey ( extension . identifier . value ) , metadata ?. yieldTo ?. map ( extId => ExtensionIdentifier . toKey ( extId ) ) || [ ] , metadata ?. debounceDelayMs ) ;
2680
+ this . _proxy . $registerInlineCompletionsSupport (
2681
+ handle ,
2682
+ this . _transformDocumentSelector ( selector , extension ) ,
2683
+ adapter . supportsHandleEvents ,
2684
+ ExtensionIdentifier . toKey ( extension . identifier . value ) ,
2685
+ metadata ?. yieldTo ?. map ( extId => ExtensionIdentifier . toKey ( extId ) ) || [ ] ,
2686
+ metadata ?. displayName ,
2687
+ metadata ?. debounceDelayMs ,
2688
+ ) ;
2687
2689
return this . _createDisposable ( handle ) ;
2688
2690
}
2689
2691
2690
2692
$provideInlineCompletions ( handle : number , resource : UriComponents , position : IPosition , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
2691
- return this . _withAdapter ( handle , InlineCompletionAdapterBase , adapter => adapter . provideInlineCompletions ( URI . revive ( resource ) , position , context , token ) , undefined , token ) ;
2693
+ return this . _withAdapter ( handle , InlineCompletionAdapter , adapter => adapter . provideInlineCompletions ( URI . revive ( resource ) , position , context , token ) , undefined , token ) ;
2692
2694
}
2693
2695
2694
2696
$provideInlineEditsForRange ( handle : number , resource : UriComponents , range : IRange , context : languages . InlineCompletionContext , token : CancellationToken ) : Promise < extHostProtocol . IdentifiableInlineCompletions | undefined > {
2695
- return this . _withAdapter ( handle , InlineCompletionAdapterBase , adapter => adapter . provideInlineEditsForRange ( URI . revive ( resource ) , range , context , token ) , undefined , token ) ;
2697
+ return this . _withAdapter ( handle , InlineCompletionAdapter , adapter => adapter . provideInlineEditsForRange ( URI . revive ( resource ) , range , context , token ) , undefined , token ) ;
2696
2698
}
2697
2699
2698
2700
$handleInlineCompletionDidShow ( handle : number , pid : number , idx : number , updatedInsertText : string ) : void {
2699
- this . _withAdapter ( handle , InlineCompletionAdapterBase , async adapter => {
2701
+ this . _withAdapter ( handle , InlineCompletionAdapter , async adapter => {
2700
2702
adapter . handleDidShowCompletionItem ( pid , idx , updatedInsertText ) ;
2701
2703
} , undefined , undefined ) ;
2702
2704
}
2703
2705
2704
2706
$handleInlineCompletionPartialAccept ( handle : number , pid : number , idx : number , acceptedCharacters : number , info : languages . PartialAcceptInfo ) : void {
2705
- this . _withAdapter ( handle , InlineCompletionAdapterBase , async adapter => {
2707
+ this . _withAdapter ( handle , InlineCompletionAdapter , async adapter => {
2706
2708
adapter . handlePartialAccept ( pid , idx , acceptedCharacters , info ) ;
2707
2709
} , undefined , undefined ) ;
2708
2710
}
2709
2711
2712
+ $handleInlineCompletionRejection ( handle : number , pid : number , idx : number ) : void {
2713
+ this . _withAdapter ( handle , InlineCompletionAdapter , async adapter => {
2714
+ adapter . handleRejection ( pid , idx ) ;
2715
+ } , undefined , undefined ) ;
2716
+ }
2717
+
2710
2718
$freeInlineCompletionsList ( handle : number , pid : number ) : void {
2711
- this . _withAdapter ( handle , InlineCompletionAdapterBase , async adapter => { adapter . disposeCompletions ( pid ) ; } , undefined , undefined ) ;
2719
+ this . _withAdapter ( handle , InlineCompletionAdapter , async adapter => { adapter . disposeCompletions ( pid ) ; } , undefined , undefined ) ;
2712
2720
}
2713
2721
2714
2722
// --- inline edit
0 commit comments