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: Add Ctrl+Shift+T shortcut to reopen the last closed Editor tab #3620

Merged
merged 16 commits into from
Dec 7, 2016

Conversation

mariacamilarg
Copy link
Contributor

@mariacamilarg mariacamilarg commented Oct 30, 2016

Fixes #2415

I rebased @thewhitetulip 's branch. He did the changes for this new feature.

@goanpeca goanpeca changed the title Last open tab PR: Last open tab Oct 31, 2016
@goanpeca goanpeca modified the milestones: v3.0.2, v3.1 Oct 31, 2016
@ccordoba12
Copy link
Member

@mariacamilaremolinagutierrez, did you verify that @thewhitetulip's additions are working correctly?

@ccordoba12 ccordoba12 changed the title PR: Last open tab PR: Add a shortcut to reopen the last closed Editor tab Oct 31, 2016
@thewhitetulip
Copy link
Contributor

@ccordoba12 I'd like to know what I did wrong back then :-)

@ccordoba12
Copy link
Member

Once Maria Camila finishes here, you'll know :-)

@mariacamilarg
Copy link
Contributor Author

So @thewhitetulip you were using the recent_files list, so you were re-opening the wrong files (that were not recently closed). Also when a file is closed it must be added to the list you will use to open from.

I just created a new list that works exactly as in a browser. It has the same size as the recent_files one. If you close spyder and open it again you can still re open last closed tabs. Which I think might me a good thing to have.

@@ -1191,6 +1198,18 @@ def close_all_but_this(self):
self.close_all_right()
for i in range(0, self.get_stack_count()-1 ):
self.close_file(0)

def add_last_closed_file(self, fname):
"""Add to last closed file list"""
Copy link
Member

Choose a reason for hiding this comment

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

Docstrings are sentences so a . is needed at the end :-)

"""Add to last closed file list."""


def add_last_closed_file(self, fname):
"""Add to last closed file list"""
if fname is None:
Copy link
Member

Choose a reason for hiding this comment

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

Is this if really needed?

@ccordoba12
Copy link
Member

@mariacamilaremolinagutierrez, please finish this one before Friday :-)

@@ -631,6 +632,15 @@ def get_plugin_actions(self):
self.register_shortcut(self.new_action, context="Editor",
name="New file", add_sc_to_tip=True)

add_shortcut_to_tooltip(self.new_action, context="Editor",
name="New file")
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this couple of lines, and the import of add_shortcut_to_tooltip. They are not needed anymore.

add_shortcut_to_tooltip(self.new_action, context="Editor",
name="New file")

self.open_last_closed = create_action(self, _("O&pen last closed"),
Copy link
Member

Choose a reason for hiding this comment

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

Please call this self.open_last_closed_action

Copy link
Member

Choose a reason for hiding this comment

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

And that's because you named the method associated with this action exactly as the action, so we need to disambiguate them :-)

@@ -976,7 +986,7 @@ def get_plugin_actions(self):
self.recent_file_menu.aboutToShow.connect(self.update_recent_file_menu)

file_menu_actions = [self.new_action,
None,
self.open_last_closed,
Copy link
Member

Choose a reason for hiding this comment

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

Don't remove None here and move self.open_last_closed after self.open_action.

We use None to create separators in our menus :-)

Copy link
Member

@goanpeca goanpeca Nov 29, 2016

Choose a reason for hiding this comment

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

# spyder.utils.qt_helpers.py
class MenuSeparator:
    pass

# some_file.py
from spyder.utils.qt_helpers import MenuSeparator

file_menu_actions = [self.new_action, 
                     MenuSeparator,
                     self.open_last_closed]

I think we could add something like MenuSeparator so that it is clear what None really does... (for another PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@goanpeca I just did that in this issue: #3794

@ccordoba12
Copy link
Member

I left some minor comments, but this is almost ready. Good work @mariacamilaremolinagutierrez!

@ccordoba12
Copy link
Member

Looking good, thanks @mariacamilaremolinagutierrez!

@ccordoba12 ccordoba12 changed the title PR: Add a shortcut to reopen the last closed Editor tab PR: Add Ctrl+Shift+T shortcut to reopen the last closed Editor tab Dec 7, 2016
@ccordoba12 ccordoba12 merged commit 1003be3 into spyder-ide:3.x Dec 7, 2016
ccordoba12 added a commit that referenced this pull request Dec 7, 2016
@mariacamilarg mariacamilarg deleted the last_open_tab branch January 1, 2017 09:21
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.

4 participants