-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: Add disambiguation for dedicated IPython consoles #4700
Conversation
spyder/plugins/ipythonconsole.py
Outdated
self.clients.insert(index_to, client) | ||
self.update_plugin_title.emit() | ||
|
||
def get_tab_text(self, fname): |
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.
get_tab_text -> disambiguate_fname
spyder/plugins/ipythonconsole.py
Outdated
self.clients.insert(index_to, client) | ||
self.update_plugin_title.emit() | ||
|
||
def get_tab_text(self, fname): | ||
"""Get tab text without ambiguation.""" |
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.
Let's change this to
"""Generate a file name without ambiguation."""
spyder/plugins/ipythonconsole.py
Outdated
|
||
# Don't increase the count of master clients | ||
self.master_clients -= 1 | ||
|
||
# Rename client tab with filename | ||
client = self.get_current_client() | ||
client.allow_rename = False | ||
self.rename_client_tab(client, filename) | ||
fname = self.get_tab_text(filename) |
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.
fname -> tab_text
spyder/plugins/ipythonconsole.py
Outdated
"""Get tab text without ambiguation.""" | ||
files_path_list = [filename for filename in self.filenames | ||
if filename is not None] | ||
return sourcecode.get_file_title(files_path_list, fname) |
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 rename get_file_title
in sourcecode
to disambiguate_fname
and make the corresponding change in the Editor.
@dalthviz, I left several comments related to renaming variables and functions to better understand your code. Also, this is missing a test. It could be like this:
|
I think this is ready. @dalthviz, could you post a screenshot to see how this looks, please? |
@@ -907,7 +909,7 @@ def write_to_stdin(self, line): | |||
|
|||
@Slot() | |||
@Slot(bool) |
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 add two more signatures below this line
@Slot(object)
@Slot(bool, object)
to cover all possible entries of create_new_client
.
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.
Sorry, give me a moment to think this.
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.
This needs to be
@Slot(str)
@Slot(bool, str)
and you need to change below
filename=''
instead of
filename=None
spyder/plugins/ipythonconsole.py
Outdated
def disambiguate_fname(self, fname): | ||
"""Generate a file name without ambiguation.""" | ||
files_path_list = [filename for filename in self.filenames | ||
if filename is not None] |
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.
With my last suggested change, you need to change this line to
if filename]
instead of
if filename is not None]
spyder/plugins/ipythonconsole.py
Outdated
def update_tabs_text(self): | ||
"""Update the text from the tabs.""" | ||
for index, fname in enumerate(self.filenames): | ||
if fname is not None: |
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.
I think this also needs to change to
if fname:
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.
Great job @dalthviz!
Fixes #4694