|
5 | 5 |
|
6 | 6 | import { localize } from '../../../../nls.js';
|
7 | 7 | import { createHotClass } from '../../../../base/common/hotReloadHelpers.js';
|
8 |
| -import { Disposable } from '../../../../base/common/lifecycle.js'; |
| 8 | +import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.js'; |
9 | 9 | import { autorunWithStore, derived } from '../../../../base/common/observable.js';
|
10 | 10 | import { debouncedObservable } from '../../../../base/common/observableInternal/utils.js';
|
11 | 11 | import Severity from '../../../../base/common/severity.js';
|
12 | 12 | import { ICodeEditor } from '../../../../editor/browser/editorBrowser.js';
|
13 | 13 | import { InlineCompletionsController } from '../../../../editor/contrib/inlineCompletions/browser/controller/inlineCompletionsController.js';
|
14 | 14 | import { ILanguageStatusService } from '../../../services/languageStatus/common/languageStatusService.js';
|
| 15 | +import { observableCodeEditor } from '../../../../editor/browser/observableCodeEditor.js'; |
15 | 16 |
|
16 | 17 | export class InlineCompletionLanguageStatusBarContribution extends Disposable {
|
17 | 18 | public static readonly hot = createHotClass(InlineCompletionLanguageStatusBarContribution);
|
18 | 19 |
|
19 | 20 | public static Id = 'vs.editor.contrib.inlineCompletionLanguageStatusBarContribution';
|
| 21 | + public static readonly languageStatusBarDisposables = new Set<DisposableStore>(); |
20 | 22 |
|
21 | 23 | private readonly _c = InlineCompletionsController.get(this._editor);
|
22 | 24 |
|
23 | 25 | private readonly _state = derived(this, reader => {
|
24 | 26 | const model = this._c?.model.read(reader);
|
25 | 27 | if (!model) { return undefined; }
|
| 28 | + if (!observableCodeEditor(this._editor).isFocused.read(reader)) { |
| 29 | + return undefined; |
| 30 | + } |
26 | 31 |
|
27 | 32 | return {
|
28 | 33 | model,
|
@@ -51,6 +56,15 @@ export class InlineCompletionLanguageStatusBarContribution extends Disposable {
|
51 | 56 | noSuggestion: { shortLabel: '$(circle-slash)', label: '$(copilot) ' + localize('noInlineSuggestionAvailable', "No inline suggestion available"), loading: false, },
|
52 | 57 | };
|
53 | 58 |
|
| 59 | + // Make sure previous status is cleared before the new is registered. This works, but is a bit hacky. |
| 60 | + // TODO: Use a workbench contribution to get singleton behavior. |
| 61 | + InlineCompletionLanguageStatusBarContribution.languageStatusBarDisposables.forEach(d => d.clear()); |
| 62 | + |
| 63 | + InlineCompletionLanguageStatusBarContribution.languageStatusBarDisposables.add(store); |
| 64 | + store.add({ |
| 65 | + dispose: () => InlineCompletionLanguageStatusBarContribution.languageStatusBarDisposables.delete(store) |
| 66 | + }); |
| 67 | + |
54 | 68 | store.add(this._languageStatusService.addStatus({
|
55 | 69 | accessibilityInfo: undefined,
|
56 | 70 | busy: statusMap[status].loading,
|
|
0 commit comments