@@ -50,6 +50,7 @@ import { generateUuid } from 'vs/base/common/uuid';
50
50
import { isEqual } from 'vs/base/common/resources' ;
51
51
import { ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents' ;
52
52
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
53
+ import { escapeRegExpCharacters } from 'vs/base/common/strings' ;
53
54
54
55
export const enum State {
55
56
CREATE_SESSION = 'CREATE_SESSION' ,
@@ -433,7 +434,7 @@ export class InlineChatController implements IEditorContribution {
433
434
} ) ) ;
434
435
435
436
// #region DEBT
436
- // DEBT@jrieken
437
+ // DEBT@jrieken https://github.com/microsoft/vscode/issues/218819
437
438
// REMOVE when agents are adopted
438
439
this . _sessionStore . add ( this . _languageFeatureService . completionProvider . register ( { scheme : ChatInputPart . INPUT_SCHEME , hasAccessToAllModels : true } , {
439
440
_debugDisplayName : 'inline chat commands' ,
@@ -456,7 +457,7 @@ export class InlineChatController implements IEditorContribution {
456
457
result . suggestions . push ( {
457
458
label : { label : withSlash , description : command . description ?? '' } ,
458
459
kind : CompletionItemKind . Text ,
459
- insertText : withSlash ,
460
+ insertText : ` ${ withSlash } ` ,
460
461
range : Range . fromPositions ( new Position ( 1 , 1 ) , position ) ,
461
462
} ) ;
462
463
}
@@ -471,16 +472,12 @@ export class InlineChatController implements IEditorContribution {
471
472
for ( const command of ( this . _session ?. agent . slashCommands ?? [ ] ) . sort ( ( a , b ) => b . name . length - a . name . length ) ) {
472
473
const withSlash = `/${ command . name } ` ;
473
474
const firstLine = model . getLineContent ( 1 ) ;
474
- if ( firstLine . startsWith ( withSlash ) ) {
475
+ if ( firstLine . match ( new RegExp ( `^ ${ escapeRegExpCharacters ( withSlash ) } (\\s|$)` ) ) ) {
475
476
newDecorations . push ( {
476
477
range : new Range ( 1 , 1 , 1 , withSlash . length + 1 ) ,
477
478
options : {
478
479
description : 'inline-chat-slash-command' ,
479
480
inlineClassName : 'inline-chat-slash-command' ,
480
- after : {
481
- // Force some space between slash command and placeholder
482
- content : ' '
483
- }
484
481
}
485
482
} ) ;
486
483
0 commit comments