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

Fix breakpoint context menu behaviour #6480

Merged
merged 1 commit into from
Nov 6, 2019

Conversation

thegecko
Copy link
Member

@thegecko thegecko commented Nov 1, 2019

Signed-off-by: thegecko [email protected]

What it does

This PR fixes #6237 by ensuring the editor window is correctly focussed and the current position is stored while managing breakpoints via the context menu.

Specifically:

  • focus the current editor widget before showing the context menu. This ensures the current and active editor is correctly set in the shell for when the context menu is shown.

  • Remove the onhide behaviour of the context menu which resets the current position. This was causing a race condition where the position was trying to be read by breakpoint management functions and it was no longer set (causing the breakpoint to appear on the first or last line).
    @akosyakov Was there any reason for the position to be reset when closing the menu? I didn't see any effects with stopping this.

  • BONUS: I noticed the onhide event for the electron menus was being fired immediately, This is now fired when the menu is closed as expected.

How to test

Please refer to issue #6237 for reproduction steps.

Review checklist

Reminder for reviewers

@thegecko thegecko added the debug issues that related to debug functionality label Nov 1, 2019
@thegecko thegecko requested review from tolusha and akosyakov November 1, 2019 14:40
@thegecko
Copy link
Member Author

thegecko commented Nov 5, 2019

it does not add a new breakpoint, but remove the breakpoint added via the context menu

Hmm, in electron this works as expected and I don't see this behaviour

@thegecko
Copy link
Member Author

thegecko commented Nov 5, 2019

@akosyakov It works fine because toggling the breakpoint without the context menu explicitly sets the position:

https://github.com/eclipse-theia/theia/blob/master/packages/debug/src/browser/editor/debug-editor-model.ts#L293

All other uses of toggle are via the context-menu and require the position to be set. I'll update the PR to tidy this slightly.

@akosyakov
Copy link
Member

sorry, I don't get it, I meant this method returns the bogus position after closing the context menu:

protected _position: monaco.Position | undefined;
get position(): monaco.Position {
return this._position || this.editor.getControl().getPosition()!;
}

testing now again

@akosyakov
Copy link
Member

It does not work for me, please see the screencast:
breakpoint

Toggle is using the wrong line after using the context menu.

@thegecko
Copy link
Member Author

thegecko commented Nov 5, 2019

Thanks for the update, I wasn't aware toggle appeared in the main menu.

I assume you can recreate the original problem?

@akosyakov
Copy link
Member

I assume you can recreate the original problem?

Sorry, i did no come to it, i've just looked at the code and though about the use case with toggle breakpoints keybinding.

@thegecko
Copy link
Member Author

thegecko commented Nov 5, 2019

Thanks for your feedback @akosyakov

PR has been updated to only use the position of the context menu for commands in the context menu. This fixes the original issue and ensures the debug commands also continue to work as expected.

@akosyakov
Copy link
Member

akosyakov commented Nov 6, 2019

I'm probably missing something: Why do we need to change APIs, won't it be enough to clean up the context position when the menu is closed as it was before:

setTimeout(() => this._position = undefined)

Got it.

@akosyakov
Copy link
Member

akosyakov commented Nov 6, 2019

I wonder whether we can pass the current position as an arg to the context menu instead of remembering it: https://github.com/ARMmbed/theia/blob/9cb7a32db69f10e2d15810e0ce27248f96f2171a/packages/core/src/browser/context-menu-renderer.ts#L37

Editor context menu commands then can use it, but it will remove a need to keep the context position which is potentially can lead to bugs as #6480 (comment)

@thegecko
Copy link
Member Author

thegecko commented Nov 6, 2019

I'll take a look, I was struggling to fix this in a clean way

@thegecko
Copy link
Member Author

thegecko commented Nov 6, 2019

Thanks @akosyakov . The PR has been updated to use the args sent to the context menu render.
This creates a much neater solution, please take a look.

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

It looks cleaner, but I don't think that the debug editor service should care whether it is called from context menu or not. It should provide APIs to manipulate breakpoints. It seems that we also lose some APIs like accessing a breakpoint for the currently selected line. It would be good to preserve them to avoid breaking downstream clients.

packages/debug/src/browser/editor/debug-editor-service.ts Outdated Show resolved Hide resolved
Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

Tested that I can add/remove/edit breakpoints from context menus, with keybindings and from the breakpoints view for editor and editor preview widgets. It worked nicely for me.

@thegecko
Copy link
Member Author

thegecko commented Nov 6, 2019

@akosyakov Updated to reflect your change requests. Have used a local isPosition() function in lieu of one available on monaco.Position.

Happy to merge?

@akosyakov
Copy link
Member

@thegecko yes, i was happy to merge before as well :)

@thegecko thegecko merged commit fa9cf9d into eclipse-theia:master Nov 6, 2019
@thegecko thegecko deleted the debug-context-menu branch November 6, 2019 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debug issues that related to debug functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[debug] Unstable behaviour with breakpoint context menu
2 participants