File tree Expand file tree Collapse file tree 3 files changed +18
-8
lines changed
src/vs/workbench/contrib/chat/common/promptSyntax Expand file tree Collapse file tree 3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export class FileReference extends PromptVariableWithData {
56
56
* Get the range of the `link` part of the token (e.g.,
57
57
* the `/path/to/file.md` part of `#file:/path/to/file.md`).
58
58
*/
59
- public get linkRange ( ) : IRange {
59
+ public get linkRange ( ) : IRange | undefined {
60
60
return super . dataRange ;
61
61
}
62
62
}
Original file line number Diff line number Diff line change @@ -125,17 +125,28 @@ export class PromptVariableWithData extends PromptVariable {
125
125
/**
126
126
* Range of the `data` part of the variable.
127
127
*/
128
- public get dataRange ( ) : IRange {
128
+ public get dataRange ( ) : IRange | undefined {
129
129
const { range } = this ;
130
+
131
+ // calculate the start column number of the `data` part of the variable
130
132
const dataStartColumn = range . startColumn +
131
133
START_CHARACTER . length + this . name . length +
132
134
DATA_SEPARATOR . length ;
133
135
134
- return new Range (
136
+ // create `range` of the `data` part of the variable
137
+ const result = new Range (
135
138
range . startLineNumber ,
136
139
dataStartColumn ,
137
140
range . endLineNumber ,
138
141
range . endColumn ,
139
142
) ;
143
+
144
+ // if the resulting range is empty, return `undefined`
145
+ // because there is no `data` part present in the variable
146
+ if ( result . isEmpty ( ) ) {
147
+ return undefined ;
148
+ }
149
+
150
+ return result ;
140
151
}
141
152
}
Original file line number Diff line number Diff line change @@ -244,21 +244,20 @@ export class PromptPathAutocompletion extends Disposable implements CompletionIt
244
244
// when character is `:`, there must be no link present yet
245
245
// otherwise the `:` was used in the middle of the link hence
246
246
// we don't want to provide suggestions for that
247
- if ( character === ':' && linkRange !== undefined ) {
247
+ if ( ( character === ':' ) && ( linkRange !== undefined ) ) {
248
248
return [ ] ;
249
249
}
250
250
251
251
// otherwise when the `.` character is present, it is inside the link part
252
252
// of the reference, hence we always expect the link range to be present
253
- if ( character === '.' && linkRange === undefined ) {
253
+ if ( ( character === '.' ) && ( linkRange === undefined ) ) {
254
254
return [ ] ;
255
255
}
256
256
257
257
const suggestions = await this . getFolderSuggestions ( fileFolderUri ) ;
258
258
259
- // replacement range of the suggestions
260
- // when character is `.` we want to also replace it, because we add
261
- // the `./` at the beginning of all the relative paths
259
+ // replacement range for suggestions; when character is `.`, we want to also
260
+ // replace it, because we add `./` at the beginning of all the relative paths
262
261
const startColumnOffset = ( character === '.' ) ? 1 : 0 ;
263
262
const range = {
264
263
...fileReference . range ,
You can’t perform that action at this time.
0 commit comments