Skip to content

Commit 0eec437

Browse files
authored
Fix broken chat variable highlights (microsoft#222322)
1 parent 1c7fa5e commit 0eec437

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
5050
this._register(widget.inputEditor.onDidChangeModelContent(e => {
5151
e.changes.forEach(c => {
5252
// Don't mutate entries in _variables, since they will be returned from the getter
53-
const originalNumVariables = this._variables.length;
53+
let didModifyState = false;
5454
this._variables = coalesce(this._variables.map(ref => {
5555
const intersection = Range.intersectRanges(ref.range, c.range);
5656
if (intersection && !intersection.isEmpty()) {
@@ -63,9 +63,11 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
6363
text: '',
6464
}]);
6565
}
66+
didModifyState = true;
6667
return null;
6768
} else if (Range.compareRangesUsingStarts(ref.range, c.range) > 0) {
6869
const delta = c.text.length - c.rangeLength;
70+
didModifyState = true;
6971
return {
7072
...ref,
7173
range: {
@@ -80,7 +82,7 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC
8082
return ref;
8183
}));
8284

83-
if (this._variables.length !== originalNumVariables) {
85+
if (didModifyState) {
8486
this._onDidChangeInputState.fire();
8587
}
8688
});

0 commit comments

Comments
 (0)