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: [WIP] Add support for editor tab reordering #2372

Closed
wants to merge 5 commits into from
Closed

PR: [WIP] Add support for editor tab reordering #2372

wants to merge 5 commits into from

Conversation

goanpeca
Copy link
Contributor

@goanpeca goanpeca commented Apr 27, 2015

Description

Any reordering event will reorder ALL editorstacks opened, so everything remains in sync. Since the editor was sorting by default, I disabled all instances were this was happenning, now we need to discuss what other options should we offer, including sorting and also extra ones (Delete tabs to the right, to the left, delete all tabs except this etc...)

My take on this is that new files should be opened in the order of opening (what happens now with this PR) and if the user wants to order them by some measure, it should be an active action from the user in the context menu.

The video

Todo

  • Make tabs moving dynamic (move tabs while dragging)
  • Erase sorting in preferences
  • Disable tab refresh when deleting a tab
  • Add support for tab scrolling when dragging with many tabs open (going to the right or left end should move the tabs)
  • Remove all code reference to fullpath sorting in the calling and creation of Editors?
  • Check nothing is broken!

For another PR

  • Offer sorting options
  • Offer additional options (Delete tabs to the right, to the left, delete all tabs except)?
  • Adapt editor preferences panel sorting options

@Nodd
Copy link
Contributor

Nodd commented Apr 27, 2015

Yes, more tabs ! 😄

👍 for dynamic tabs (realtime moving while dragging), it's more obvious to see what happens.

@ccordoba12
Copy link
Member

This is fantastic!!! Thanks a lot for working on it! :-)

My opinions about your todos:

  1. I agree too that new files should be opened in the order of opening. I think right now we're auto-sorting them by their path, but that's not intuitive.
  2. This PR should also solve the issue of tab scrolling, not only when dragging but also when closing a file. I mean, there is a very annoying effect right now when closing a file and the tab scrolling buttons are on: the file you're trying to close is (automatically) made the last one from left to the right, regardless of its position. We should change that and not move tabs at all when closing files.
  3. Let's leave new features (like new sorting options and additional options) for additional PRs. That will make my life as a reviewer much easier because I won't need to check for correctness of several things in a single PR.

@goanpeca
Copy link
Contributor Author

Should I remove the option in preferences in this PR Sort files according to fullpath?

image

@ccordoba12
Copy link
Member

Yes, please. Let's leave new things for further PRs ;-)

@Nodd
Copy link
Contributor

Nodd commented Apr 27, 2015

It's not a new thing, it's an old thing :)

@ccordoba12
Copy link
Member

I know, but right now I'm not so sure if the best thing is to preserve the previous behavior, and doing so by adding (yet another) option to our crowded Preferences.

But instead of discussing that here, I'd prefer to do it in another PR, so I can review and merge this one quickly :-)

@goanpeca
Copy link
Contributor Author

Well.. the thing is, in this PR I commented the lines were sorting took place, so right now the option in preferences does nothing, and I would rather comment it (than erase it) so we can focus on things and move on. It would be weird to merge this PR but leave the option there.

@goanpeca
Copy link
Contributor Author

You agree on the grabbing hand icon (ClosedHand) when dragging?

Or any other suggestion from here

@ccordoba12
Copy link
Member

Yes, I'd like to see the CloseHand icon when dragging.

@goanpeca
Copy link
Contributor Author

@ccordoba12 I think I solved the issue you commented, but there is still another one that is quite annoying. If you have many tabs open and the scrolling buttons are there, if you click on file closer to the left, the whole tabs will shift and put the current clicked tab to the right... very weird behavior...

@Nodd
Copy link
Contributor

Nodd commented Apr 27, 2015

Sorry for my previous comment, I was just nitpicking. I agree that the option should be removed for now (and it should be added to the context menu for tabs, this is the case where it makes sense).

@goanpeca
Copy link
Contributor Author

The code in editor.py gives me headaches...

@goanpeca
Copy link
Contributor Author

hmmm I think it is a Qt limitation (https://bugreports.qt.io/browse/QTBUG-2360?jql=text%20~%20%22QTabBar%20Scroll%22) that when you setCurrentIndex for a specific tab, if many tabs (and a scroll buttons present) it will always slide the selected tab to the right of the QTabBar, instead of just selecting the tab where it is.

This leads to weird behaviors when moving tabs... so the best to have here would be shortcuts to move tabs (Ctrl+Shift+PgUp/PgDn)

fpsorting_box = newcb(_("Sort files according to full path"),
'fullpath_sorting')
# fpsorting_box = newcb(_("Sort files according to full path"),
# 'fullpath_sorting')
Copy link
Member

Choose a reason for hiding this comment

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

So this was a current option? Then we should remove it in this PR because our decision is to order files according to their opening order.

@Nodd
Copy link
Contributor

Nodd commented Apr 28, 2015

Your video examples are really cool!

I don't like the second part very much, not having the tab on the right or left end when scrolling is disturbing. The way Firefox does it is more intuitive for me: basically, you have to put the mouse pointer outside the tabbbar, then it scrolls at a given speed (faster if the mouse is further on the side).

@goanpeca
Copy link
Contributor Author

@Nodd I do not understand this "not having the tab on the right or left end when scrolling is disturbing". What you suggest is harder to implement right due to the way the tabbar is designed

@goanpeca
Copy link
Contributor Author

@Nodd I just checked with Firefox... I do not like it so much cause it is too fast, the user has no real control...

@Nodd
Copy link
Contributor

Nodd commented Apr 28, 2015

es the speed is a bit too fast (I think it's needed with lots of tabs: you scroll a bit too much, the you go back 2 or 3 tabs without scrolling), but I find the principle better.
To be clear: your version is already very good. Actually I don't understand your question, do you already think about another way of doing it ?

@goanpeca
Copy link
Contributor Author

I tried the firefox approach first, but I could not come up with reliable code .. then I asked the question, then I figured doing it how I did it in the video.

But now I have more tools so I can revisit the firefox version....

@goanpeca
Copy link
Contributor Author

goanpeca commented May 1, 2015

@Nodd I got it to work more like firefox (not as fast!), it is not 100% perfect (I need to look why...), but it is looking good :-)

@Nodd
Copy link
Contributor

Nodd commented May 1, 2015

Nice !

@goanpeca
Copy link
Contributor Author

goanpeca commented May 4, 2015

question @ccordoba12 ...

So I have a new set of classes that will replace the existing ones so that we have an uniform support for tab handling.

But the change will include modifications to the consoles and other parts of spyder (where Tabs are used), so... should I add the new classes with the existing ones and make it work only with the editor in the meantime, and in another PR I adapt the consoles to use the new classes, (and hence erase the old classes)

I guess it would make this PR more manageable, and avoid breaking something

@ccordoba12
Copy link
Member

Yes, I agree with your plan. First use the new classes only to fix the problems we have in the Editor. Then (in another PR) use them to improve things in our consoles.

May I ask what's exactly the difference between your new classes and the old ones?

@goanpeca
Copy link
Contributor Author

goanpeca commented May 5, 2015

The actual scheme has TabBar, BaseTab, Tab.

BaseTab has no drag and drop support and is used by the editors and Tab (Which uses TabBar) has drag and drop support and is used by the consoles.

I will create a new TabBar and then a new (that uses a lot of the existing code) Tab (That will use the new TabBar), and then Tab will be used by both the editor and consoles and will allow for tab reordering (similar to Drag and drop but done in a simpler way) and also will allow for having specific contextual menus in tabs, nontabs, and even the scroll buttons (if needed).

This will also allow to completely delegate the tab reordering behavior to tabs.py so that the editor can concentrate on being an editor (different of the current code in this PR, which I will update soon)

@ccordoba12
Copy link
Member

Thanks for the explanation! Sounds really good, please proceed :-)

@goanpeca goanpeca mentioned this pull request May 7, 2015
@bbenneke
Copy link

This is great! Thank you for working on this.

Is it also possible to move the tab bar to the left? Similar to Matlab, TextWrangler, Firefox, etc.?
I found that a tab bar on the left is absolutely needed if more than ~5 files are open.

See screenshot.

screen shot 2015-07-20 at 14 31 56

@goanpeca
Copy link
Contributor Author

@ben1983 thanks for the input. Have you tried using the outline explorer for what you suggest?, the outline explorer displays all the opened (if you enable the functionality) files.

The feature requested will not be implemented on this pull request, but I will take note of it.

Cheers

@bbenneke
Copy link

@goanpeca Thank you for the quick response. Yes, I am using the outline explorer. The problems with the outline explorer are:

  1. similar to the tab bar, one cannot change the order of the files in the outline explorer. This make repeated switching between files extremely confusing when 8-10 files are open.
  2. when you click on a file in the outline explorer, the outline explorer always open the tree view and shows all the function and loops within that file. If you have >20 functions and loops in one file (which is totally common), all the other files are moved to the bottom off the screen. Switching back and forth becomes a hassle. My suggestions would be: 1) single click to change to the selected file without opening the tree view, 2) double click on a file to open the tree displaying the functions within that file.
    Is that hard to implement?

@ccordoba12
Copy link
Member

This needs a rebase, and I think it's really important to finish it :-)

@goanpeca goanpeca changed the title [WIP] Add support for editor tab reordering PR: [WIP] Add support for editor tab reordering Jan 27, 2016
@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.0 Jan 27, 2016
@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.0rc1 Apr 25, 2016
@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.0rc1 Jun 9, 2016
@oldrichsmejkal
Copy link

What about this issue? It's pretty old, and it would be nice to have this features...

Thanks.

@ccordoba12 ccordoba12 removed this from the v3.0beta5 milestone Jul 23, 2016
@ccordoba12
Copy link
Member

Closing because @goanpeca has a different approach to solve this. It'll be fixed in 3.1 ;-)

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.

5 participants