Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/vs/editor/contrib/inlineEdit/browser/inlineEditController.ts
Expand Up @@ -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;
Expand All @@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For focus, I can recommend to have an isFocused: IObservable<boolean>, instead of having two signals indicating the state transitions.

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);
}));


Expand Down