Skip to content

Commit d816496

Browse files
authored
chat - update status based on language changes too (#245166) (#245200)
1 parent bd52319 commit d816496

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { ITelemetryService } from '../../../../platform/telemetry/common/telemet
3737
import { IChatStatusItemService, ChatStatusEntry } from './chatStatusItemService.js';
3838
import { ITextResourceConfigurationService } from '../../../../editor/common/services/textResourceConfiguration.js';
3939
import { EditorResourceAccessor, SideBySideEditor } from '../../../common/editor.js';
40+
import { getCodeEditor } from '../../../../editor/browser/editorBrowser.js';
4041

4142
const gaugeBackground = registerColor('gauge.background', {
4243
dark: inputValidationInfoBorder,
@@ -103,6 +104,8 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
103104

104105
private dashboard = new Lazy<ChatStatusDashboard>(() => this.instantiationService.createInstance(ChatStatusDashboard));
105106

107+
private readonly activeCodeEditorListener = this._register(new MutableDisposable());
108+
106109
constructor(
107110
@IChatEntitlementService private readonly chatEntitlementService: ChatEntitlementService,
108111
@IInstantiationService private readonly instantiationService: IInstantiationService,
@@ -136,14 +139,30 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
136139
this._register(this.chatEntitlementService.onDidChangeQuotaExceeded(() => this.entry?.update(this.getEntryProps())));
137140
this._register(this.chatEntitlementService.onDidChangeSentiment(() => this.entry?.update(this.getEntryProps())));
138141
this._register(this.chatEntitlementService.onDidChangeEntitlement(() => this.entry?.update(this.getEntryProps())));
139-
this._register(this.editorService.onDidActiveEditorChange(() => this.entry?.update(this.getEntryProps())));
142+
143+
this._register(this.editorService.onDidActiveEditorChange(() => this.onDidActiveEditorChange()));
144+
140145
this._register(this.configurationService.onDidChangeConfiguration(e => {
141146
if (e.affectsConfiguration(defaultChat.completionsEnablementSetting)) {
142147
this.entry?.update(this.getEntryProps());
143148
}
144149
}));
145150
}
146151

152+
private onDidActiveEditorChange(): void {
153+
this.entry?.update(this.getEntryProps());
154+
155+
this.activeCodeEditorListener.clear();
156+
157+
// Listen to language changes in the active code editor
158+
const activeCodeEditor = getCodeEditor(this.editorService.activeTextEditorControl);
159+
if (activeCodeEditor) {
160+
this.activeCodeEditorListener.value = activeCodeEditor.onDidChangeModelLanguage(() => {
161+
this.entry?.update(this.getEntryProps());
162+
});
163+
}
164+
}
165+
147166
private getEntryProps(): IStatusbarEntry {
148167
let text = '$(copilot)';
149168
let ariaLabel = localize('chatStatus', "Copilot Status");

0 commit comments

Comments
 (0)