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

PR: Prevent Editor dockwidget to become visible when clicking on the outline explorer if the Editor is in a separate window #5742

Merged

Conversation

jnsebgosselin
Copy link
Member

@jnsebgosselin jnsebgosselin commented Nov 14, 2017

Fixes #2883

Before PR #3824, Issue #2883 was hard to reproduce. But now that separate windows are created by default when undocking widgets, this issue has become easily reproducible and is much more annoying. One simply has to undock the editor and click on the outline explorer to trigger it (see animation below).

This is due to the fact that a setVisible(True), setFocus() and raise_() is systematically called on the editor dockwidget in the load method, which is the method that is connected to the action of clicking on the outline explorer. To fix Issue #2883, we simply have to prevent these calls when the editor is in a separate window and call setFocus and raise_() on this separate window instead.

outline_focus_dockwidget

@jnsebgosselin
Copy link
Member Author

Moreover, in this PR, we are also forcing the docked outline explorer to connect to the editor in the separate window instead of connecting to the invisible docked editor. This is done by overriding the value of the editorwindow variable that was passed as argument by the edit_goto signal of the outline explorer with editorwindow = self.editorwindows[0].

fixed_outline_focus_dockwidget

@jnsebgosselin
Copy link
Member Author

Also, fixing this issue for the 3.x branch is a little bit more complicated because in this branch one or more editors in separate windows are allowed to live at the same time alongside a docked editor. I'll try to see what I can do and I will submit another PR for the 3.x branch if I find an acceptable solution.

@jnsebgosselin
Copy link
Member Author

I will continue to work on this one to see if I could find a way to fix this for Spyder 3 and 4 with a single PR. Below I try to summarize a little bit more the situation and the main difference between Spyder 3 and 4 and what is the behaviour I think should be expected when clicking on the outline explorer.

Spyder 3

In Spyder 3, undocking the editor will simply undock the dockwidget in which the editor lives. It is however possible to open an unlimited amount of new editorstack instances in separate window through the action "New Window" in the cog menu. Opening an editorstack in a new window will not hide the dockwidget. Therefore in Spyder 3, a docked editor can live alongside one or more editors in separate windows. This is why Issue #2883 is harder (but not impossible) to fix for Spyder 3 than 4.

image

Spyder 4

PR #3824 changed this behaviour in Spyder4. Undocking the editor while Lock panes is checked will now open a new editorstack instance in a separate window. The editorstacks that lived in the dockwidget are automatically hidden when doing this, but are not destroyed. They are restored when the separate editor window is closed. In Spyder4, it is not possible anymore to generate more than one separate editor window. So if I understand correctly PR #3824, the intended behaviour in Spyder 4 is to have the editor either in a dockwidget or in a unique separate window, but not both at the same time.

So following this line of thoughts, here is what I think should happen in Spyder 4 when clicking on the outline explorer:

  • Clicking on either the sidebar or docked outline explorer while the editor is in a separate window should focus and return to the editor in the separate window. This operation should not focus and make the dockwidget visible like it currently does.

  • Clicking on the docked outline explorer while there is no editor visible at all should focus the main editorstack and make the editor dockwidget visible again.

  • Clicking on the outline explorer while the editor is in a dockwidget should focus and return to the last focused editor in the current editorstack of the dockwidget.

@jnsebgosselin jnsebgosselin changed the title PR: Prevent editor dockwidget to become visible when clicking on the outline explorer when the editor is in PR: Prevent the editor dockwidget to become visible when clicking on the outline explorer when the editor is in a separate window Nov 14, 2017
@ccordoba12 ccordoba12 added this to the v4.0beta2 milestone Nov 14, 2017
@ccordoba12
Copy link
Member

My thoughts:

  1. Please don't waste your time with Spyder 3. The solution there seems quite complex and probably we won't be able to merge it with master. Besides, it's not a terribly bad bug to spend a lot of time with it.
  2. You're right about our proposed solution for Spyder 4, i.e. Spyder will only have one Editor instance visible all the time (either docked or in a new window). The same goes for all other plugins.
  3. I agree with all the thoughts you proposed about what should happen in Spyder 4 when clicking on the outline explorer.

@jnsebgosselin
Copy link
Member Author

This PR also fixes the undesired behaviour when opening a file from the the Spyder mainwindow when the editor is in a separate window.

fixed_outline_focus_dockwidget2

@jnsebgosselin
Copy link
Member Author

Thank you @ccordoba12 for your inputs!

I've made some minor changes and tested it for Spyder 3. The PR solve the undesired behaviour reported in Issue #2883 for Spyder 3. The only thing that doesn't work perfectly in Spyder3 is when multiple editorwindows were created and a edit_goto is emitted from the mainwindow while the editor dockwidget is not visible. In this case, because there is no way to easily get the last focused editorwindow, the first editorwindow in the list will be focused.

Everything else seems to be working as expected though.

@ccordoba12 ccordoba12 changed the base branch from master to 3.x November 14, 2017 23:53
@ccordoba12 ccordoba12 changed the base branch from 3.x to master November 14, 2017 23:54
@ccordoba12
Copy link
Member

Everything else seems to be working as expected though.

Great! Thanks a lot for taking a look at this! Please move this PR to 3.x so we can start to review it.

@dalthviz, please review Jean's work.

@ccordoba12 ccordoba12 requested a review from dalthviz November 14, 2017 23:55
@jnsebgosselin jnsebgosselin changed the base branch from master to 3.x November 15, 2017 02:42
@jnsebgosselin jnsebgosselin force-pushed the fix_neweditor_if_detached_and_outline branch from be7e455 to 0a52d8d Compare November 15, 2017 03:03
@ccordoba12 ccordoba12 modified the milestones: v4.0beta2, v3.2.5 Nov 15, 2017
@ccordoba12
Copy link
Member

Pinging @dalthviz again about this one ;-)

Copy link
Member

@ccordoba12 ccordoba12 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks Jean!

@ccordoba12 ccordoba12 changed the title PR: Prevent the editor dockwidget to become visible when clicking on the outline explorer when the editor is in a separate window PR: Prevent Editor dockwidget to become visible when clicking on the outline explorer if the Editor is in a separate window Nov 27, 2017
@ccordoba12 ccordoba12 merged commit 7a978f4 into spyder-ide:3.x Nov 27, 2017
ccordoba12 added a commit that referenced this pull request Nov 27, 2017
@jnsebgosselin jnsebgosselin deleted the fix_neweditor_if_detached_and_outline branch January 4, 2018 04:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants