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

Guard active widget tracking for undefined value #75

Merged
merged 1 commit into from
May 19, 2021

Conversation

planger
Copy link
Member

@planger planger commented May 19, 2021

@planger planger requested a review from martin-fleck-at May 19, 2021 17:38
@tortmayr tortmayr self-requested a review May 19, 2021 18:44
@@ -151,7 +151,7 @@ export class GLSPDiagramWidget extends DiagramWidget implements SaveableSource {
listenToFocusState(shell: ApplicationShell): void {
this.toDispose.push(shell.onDidChangeActiveWidget(event => {
const focusedWidget = event.newValue;
if (this.hasFocus && !this.isThisWidget(focusedWidget)) {
if (this.hasFocus && focusedWidget && !this.isThisWidget(focusedWidget)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe its better to directly include the undefined check into the isThisWidget() guard function? e.g:

protected isThisWidget(widget?: Widget | null): boolean {
        // eslint-disable-next-line no-null/no-null
        if (!widget || widget === null) {
            return false;
        }
        const diagramWidget = getDiagramWidget(widget);
        return diagramWidget !== undefined && diagramWidget.id === this.id;
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but that is not the same behavior, is it?
We want to omit checking whether it is this.isthisWidget() altogether if it is null. In your version, if focusedWidget is null, we'd return false and send out the FocusStateChangedAction even though the focusedWidget was null and no other widget.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see. i overlooked the ! operator in front of this.isThisWidget 😄.
In that case, ignore my comment and lets merge this 😉

@tortmayr tortmayr self-requested a review May 19, 2021 19:32
Copy link
Contributor

@tortmayr tortmayr left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@tortmayr tortmayr merged commit 5390c14 into master May 19, 2021
@tortmayr tortmayr deleted the planger/issues/243 branch May 19, 2021 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theia diagram widget is shown as inactive when initially opened
2 participants