debt - use `observableConfigValue` (#235508)

pull/235510/head^2
Johannes Rieken 2024-12-06 17:30:17 +01:00 committed by GitHub
parent 8270a86019
commit d6faa5b076
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 8 deletions

View File

@ -33,11 +33,11 @@ import { IContextMenuService } from '../../../../platform/contextview/browser/co
import { toAction } from '../../../../base/common/actions.js';
import { IMouseEvent } from '../../../../base/browser/mouseEvent.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { Event } from '../../../../base/common/event.js';
import { observableCodeEditor } from '../../../../editor/browser/observableCodeEditor.js';
import { PLAINTEXT_LANGUAGE_ID } from '../../../../editor/common/languages/modesRegistry.js';
import { createStyleSheet2 } from '../../../../base/browser/domStylesheets.js';
import { stringValue } from '../../../../base/browser/cssValue.js';
import { observableConfigValue } from '../../../../platform/observable/common/platformObservableUtils.js';
export const CTX_INLINE_CHAT_SHOWING_HINT = new RawContextKey<boolean>('inlineChatShowingHint', false, localize('inlineChatShowingHint', "Whether inline chat shows a contextual hint"));
@ -208,10 +208,9 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
const decos = this._editor.createDecorationsCollection();
const editorObs = observableCodeEditor(editor);
const keyObs = observableFromEvent(keybindingService.onDidUpdateKeybindings, _ => keybindingService.lookupKeybinding(ACTION_START)?.getLabel());
const configSignal = observableFromEvent(Event.filter(_configurationService.onDidChangeConfiguration, e => e.affectsConfiguration(InlineChatConfigKeys.LineEmptyHint) || e.affectsConfiguration(InlineChatConfigKeys.LineNLHint)), () => undefined);
const configHintEmpty = observableConfigValue(InlineChatConfigKeys.LineEmptyHint, false, this._configurationService);
const configHintNL = observableConfigValue(InlineChatConfigKeys.LineNLHint, false, this._configurationService);
const showDataObs = derived(r => {
const ghostState = ghostCtrl?.model.read(r)?.state.read(r);
@ -222,8 +221,6 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
const kb = keyObs.read(r);
configSignal.read(r);
if (ghostState !== undefined || !kb || !position || !model || !textFocus) {
return undefined;
}
@ -237,12 +234,12 @@ export class InlineChatHintsController extends Disposable implements IEditorCont
const isWhitespace = model.getLineLastNonWhitespaceColumn(position.lineNumber) === 0 && model.getValueLength() > 0 && position.column > 1;
if (isWhitespace) {
return _configurationService.getValue(InlineChatConfigKeys.LineEmptyHint)
return configHintEmpty.read(r)
? { isEol, isWhitespace, kb, position, model }
: undefined;
}
if (visible && isEol && _configurationService.getValue(InlineChatConfigKeys.LineNLHint)) {
if (visible && isEol && configHintNL.read(r)) {
return { isEol, isWhitespace, kb, position, model };
}