Don't run onDidBlurEditorWidget and onDidFocusEditorText if inline edit is disabled (#205378)

This commit is contained in:
Krzysztof Cieślak 2024-02-19 13:56:47 +01:00 committed by GitHub
parent b128796cd8
commit 7329258fc9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,7 +110,13 @@ export class InlineEditController extends Disposable {
}));
//Clear suggestions on lost focus
this._register(editor.onDidBlurEditorWidget(() => {
const editorBlurSingal = observableSignalFromEvent('InlineEditController.editorBlurSignal', editor.onDidBlurEditorWidget);
this._register(autorun(reader => {
/** @description InlineEditController.editorBlur */
if (!this._enabled.read(reader)) {
return;
}
editorBlurSingal.read(reader);
// This is a hidden setting very useful for debugging
if (this._configurationService.getValue('editor.experimentalInlineEdit.keepOnBlur') || editor.getOption(EditorOption.inlineEdit).keepOnBlur) {
return;
@ -121,11 +127,14 @@ export class InlineEditController extends Disposable {
}));
//Invoke provider on focus
this._register(editor.onDidFocusEditorText(async () => {
if (!this._enabled.get()) {
const editorFocusSignal = observableSignalFromEvent('InlineEditController.editorFocusSignal', editor.onDidFocusEditorText);
this._register(autorun(reader => {
/** @description InlineEditController.editorFocus */
if (!this._enabled.read(reader)) {
return;
}
await this.getInlineEdit(editor, true);
editorFocusSignal.read(reader);
this.getInlineEdit(editor, true);
}));