|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import { CancellationToken } from 'vs/base/common/cancellation';
|
| 7 | +import { Iterable } from 'vs/base/common/iterator'; |
7 | 8 | import { Disposable } from 'vs/base/common/lifecycle';
|
8 | 9 | import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
9 | 10 | import { Position } from 'vs/editor/common/core/position';
|
@@ -44,6 +45,7 @@ class InputEditorDecorations extends Disposable {
|
44 | 45 | @ICodeEditorService private readonly codeEditorService: ICodeEditorService,
|
45 | 46 | @IThemeService private readonly themeService: IThemeService,
|
46 | 47 | @IChatService private readonly chatService: IChatService,
|
| 48 | + @IChatVariablesService private readonly chatVariablesService: IChatVariablesService, |
47 | 49 | ) {
|
48 | 50 | super();
|
49 | 51 |
|
@@ -175,21 +177,22 @@ class InputEditorDecorations extends Disposable {
|
175 | 177 | this.widget.inputEditor.setDecorationsByType(decorationDescription, slashCommandTextDecorationType, []);
|
176 | 178 | }
|
177 | 179 |
|
178 |
| - // const variables = this.chatVariablesService.getVariables(); |
| 180 | + const variables = this.chatVariablesService.getVariables(); |
179 | 181 | const variableReg = /(^|\s)@(\w+)(:\d+)?(?=(\s|$))/ig;
|
180 | 182 | let match: RegExpMatchArray | null;
|
181 | 183 | const varDecorations: IDecorationOptions[] = [];
|
182 | 184 | while (match = variableReg.exec(inputValue)) {
|
183 |
| - // const candidate = match[2]; |
184 |
| - // if (Iterable.find(variables, v => v.name === candidate)) |
185 |
| - varDecorations.push({ |
186 |
| - range: { |
187 |
| - startLineNumber: 1, |
188 |
| - endLineNumber: 1, |
189 |
| - startColumn: match.index! + match[1].length + 1, |
190 |
| - endColumn: match.index! + match[0].length + 1 |
191 |
| - } |
192 |
| - }); |
| 185 | + const varName = match[2]; |
| 186 | + if (Iterable.find(variables, v => v.name === varName)) { |
| 187 | + varDecorations.push({ |
| 188 | + range: { |
| 189 | + startLineNumber: 1, |
| 190 | + endLineNumber: 1, |
| 191 | + startColumn: match.index! + match[1].length + 1, |
| 192 | + endColumn: match.index! + match[0].length + 1 |
| 193 | + } |
| 194 | + }); |
| 195 | + } |
193 | 196 | }
|
194 | 197 |
|
195 | 198 | this.widget.inputEditor.setDecorationsByType(decorationDescription, variableTextDecorationType, varDecorations);
|
|
0 commit comments