Skip to content

Commit 1ae48f1

Browse files
authored
1 parent 2e3a1d8 commit 1ae48f1

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/vs/workbench/contrib/inlineChat/browser/inlineChatController.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { generateUuid } from 'vs/base/common/uuid';
5050
import { isEqual } from 'vs/base/common/resources';
5151
import { ChatAgentLocation } from 'vs/workbench/contrib/chat/common/chatAgents';
5252
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService';
53+
import { escapeRegExpCharacters } from 'vs/base/common/strings';
5354

5455
export const enum State {
5556
CREATE_SESSION = 'CREATE_SESSION',
@@ -433,7 +434,7 @@ export class InlineChatController implements IEditorContribution {
433434
}));
434435

435436
// #region DEBT
436-
// DEBT@jrieken
437+
// DEBT@jrieken https://github.com/microsoft/vscode/issues/218819
437438
// REMOVE when agents are adopted
438439
this._sessionStore.add(this._languageFeatureService.completionProvider.register({ scheme: ChatInputPart.INPUT_SCHEME, hasAccessToAllModels: true }, {
439440
_debugDisplayName: 'inline chat commands',
@@ -456,7 +457,7 @@ export class InlineChatController implements IEditorContribution {
456457
result.suggestions.push({
457458
label: { label: withSlash, description: command.description ?? '' },
458459
kind: CompletionItemKind.Text,
459-
insertText: withSlash,
460+
insertText: `${withSlash} `,
460461
range: Range.fromPositions(new Position(1, 1), position),
461462
});
462463
}
@@ -471,16 +472,12 @@ export class InlineChatController implements IEditorContribution {
471472
for (const command of (this._session?.agent.slashCommands ?? []).sort((a, b) => b.name.length - a.name.length)) {
472473
const withSlash = `/${command.name}`;
473474
const firstLine = model.getLineContent(1);
474-
if (firstLine.startsWith(withSlash)) {
475+
if (firstLine.match(new RegExp(`^${escapeRegExpCharacters(withSlash)}(\\s|$)`))) {
475476
newDecorations.push({
476477
range: new Range(1, 1, 1, withSlash.length + 1),
477478
options: {
478479
description: 'inline-chat-slash-command',
479480
inlineClassName: 'inline-chat-slash-command',
480-
after: {
481-
// Force some space between slash command and placeholder
482-
content: ' '
483-
}
484481
}
485482
});
486483

0 commit comments

Comments
 (0)