-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Redesign file switcher (a la Sublime Text) #2590
Conversation
This needs a rebase now :-) Also waiting badly for it (just saying ;-) |
I want to implement symbol lookup, it is not that hard from what is already in place... but to have perhaps some testing, we could leave symbol lookup for another one? |
I think there's a lot here, so yes, symbol lookup can wait for another PR. |
One last thing: is the new file switcher centered on the Editor when shown? Or on the entire application? |
At this moment, editor |
Mmmh, I think it'd look better to center it on the entire application (like the "Go to line" dialog). But I'm not sure |
For what its worth, Sublime centers on the active editor pane. |
I thought that was the case. The good thing about Sublime is that (by default) it only has two panes: a (small) file explorer to the left and an editor to the right. But since our editor takes half of the screen, centering the new switcher just on that area seems a bit awkward to me (specially on small screens). @goanpeca, what do you think? |
When you have a two-column view open in Sublime, it is still centered on the active column. This feels more natural as it lets you know where you are taking action. |
I agree with blinkie |
Ok, let's leave it like that for now :-) We can revisit this decision later. Then, please rebase to give this a final review ;-) |
(Note: I don't really understand this, but I seem to have made it work.)
"live" meaning, as you move up/down the list, change the active tab. And "cancel" meaning, if you hit Esc you return to where you were.
bugfix - remember selecction correctly when updating search string
SPOILER: there seems to be a bug with the Oxygen theme of Kubuntu which does not display the list items at all , it seems to work fine on the rest though |
@d1manson (if you are curious...) |
What do you mean by the spoiler? Could you post a screenshot please? |
@blink1073 can you give it a test drive? |
def update_filelistdialog(self): | ||
if not self.tabs.count(): | ||
return | ||
e = self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this. Just use self
below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok (leftover code ;- ) not from me)
I really don't have time to review the new So let's wait for @blink1073 approval, after a little bit of live testing (given that he's the one who has used Sublime the most :-) |
Uh oh: Traceback (most recent call last):
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/spyder.py", line 2471, in call_file_switcher
self.editor.get_current_editorstack().open_fileswitcher_dlg()
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/editor.py", line 539, in open_fileswitcher_dlg
self.fileswitcher_dlg = FileSwitcher(self, self.tabs, self.data)
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/file_switcher.py", line 277, in __init__
self.setup()
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/file_switcher.py", line 573, in setup
self.setup_file_list(filter_text, current_path)
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/file_switcher.py", line 459, in setup_file_list
short_paths = shorten_paths(self.paths, self.save_status)
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/file_switcher.py", line 183, in shorten_paths
recurse_level({i: pl for i, pl in enumerate(path_list) if pl})
File "/Users/ssilvester/workspace/spyder-ide/spyderlib/widgets/file_switcher.py", line 125, in recurse_level
sample_toks = level_idx.values()[0]
TypeError: 'dict_values' object does not support indexing |
What the f*ck? Just by pressing Ctrl+P ? or when doing something? your setup? |
I cannot reproduce this :-( ... |
Are you using Python 2? Here's a diff that makes it work for me on 3.4: diff --git a/spyderlib/widgets/file_switcher.py b/spyderlib/widgets/file_switcher.py
index c595127..6eab885 100644
--- a/spyderlib/widgets/file_switcher.py
+++ b/spyderlib/widgets/file_switcher.py
@@ -9,6 +9,7 @@ from __future__ import print_function
import os
import os.path as osp
+import six
from spyderlib.qt.QtGui import (QDialog, QHBoxLayout, QIcon, QLabel, QLineEdit,
QListWidget, QListWidgetItem, QRegExpValidator,
@@ -122,7 +123,7 @@ def shorten_paths(path_list, is_unsaved):
# Firstly, find the longest common prefix for all in the level
# s = len of longest common prefix
- sample_toks = level_idx.values()[0]
+ sample_toks = list(level_idx.values())[0]
if not sample_toks:
s = 0
else:
@@ -157,7 +158,7 @@ def shorten_paths(path_list, is_unsaved):
group = prospective_group
break
# Only keep going if all n still match on the kth token
- _, sample_toks = next(group.iteritems())
+ _, sample_toks = next(six.iteritems(group))
prospective_group = {idx: toks for idx, toks
in group.items()
if toks[k] == sample_toks[k]}
@@ -166,7 +167,7 @@ def shorten_paths(path_list, is_unsaved):
k += 1
else:
break
- _, sample_toks = next(group.iteritems())
+ _, sample_toks = next(six.iteritems(group))
if k == 0:
short_form = ''
elif k == 1: |
Other than those two issues, I like it 😜 |
Sh#@, I forgot to test on py3.... will make the fix thanks! |
Ok, maybe we need some custom css rules for OSX, it does look funky.... |
In spyder we do not use six... we have our own |
Yeah at some point any large project ends up using |
@blink1073 can you check again? I will look the contrast issue in a mac this week (I have a mac for a week 😸). |
@ccordoba12 I updated the description with some screenshots... But it would be nice if you can test it yourself directly |
for key in oedata: | ||
val = oedata[key] | ||
if val and val != 'found_cell_separators': | ||
if val.is_class_or_function(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the file has cells I get the following error here:
AttributeError: 'bool' object has no attribute 'is_class_or_function'
If you simply create an empty file and add a #%%
line you get this error.
@goanpeca thanks for taking over on this! Symbols lookup is a massive help...if it's not too difficult could you show something a bit more like the tree "path" you see in the outline widget, i.e. |
@d1manson, thanks for the heads up, I will see if we can get a more clean display, this is the first iteration, which I think (when I get the cells error fixed) is good for Beta2!, we need people testing this. Cheers |
Redesign file switcher (a la Sublime Text)
Fixes #2340
Fixes #2141
Description
Continues where PR #2343 left.
The file switcher now looks like this:
File list
Symbol list
Original Features
New Features
Todo
For another PR