-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PR: Add Ctrl+Shift+T shortcut to reopen the last closed Editor tab #3620
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
Changes from 15 commits
7c845ae
8668d14
159c282
268a5f4
468c828
7514107
e33369b
ad2e96f
557e350
7a39e14
cfaddd0
98c85a5
c127d8e
3db633a
8140e17
ff635d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,8 @@ | |
from spyder.utils import codeanalysis, encoding, programs, sourcecode | ||
from spyder.utils import icon_manager as ima | ||
from spyder.utils.introspection.manager import IntrospectionManager | ||
from spyder.utils.qthelpers import add_actions, create_action | ||
from spyder.utils.qthelpers import (create_action, add_actions, | ||
add_shortcut_to_tooltip) | ||
from spyder.widgets.findreplace import FindReplace | ||
from spyder.widgets.editor import (EditorMainWindow, EditorSplitter, | ||
EditorStack, Printer) | ||
|
@@ -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") | ||
|
||
self.open_last_closed = create_action(self, _("O&pen last closed"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please call this There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :-) |
||
tip=_("Open last closed"), | ||
triggered=self.open_last_closed) | ||
self.register_shortcut(self.open_last_closed, context="Editor", | ||
name="Open last closed") | ||
|
||
self.open_action = create_action(self, _("&Open..."), | ||
icon=ima.icon('fileopen'), tip=_("Open file"), | ||
triggered=self.load, | ||
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't remove We use There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
self.open_action, | ||
self.recent_file_menu, | ||
None, | ||
|
@@ -1608,7 +1618,7 @@ def __add_recent_file(self, fname): | |
self.recent_files.insert(0, fname) | ||
if len(self.recent_files) > self.get_option('max_recent_files'): | ||
self.recent_files.pop(-1) | ||
|
||
def _clone_file_everywhere(self, finfo): | ||
"""Clone file (*src_editor* widget) in all editorstacks | ||
Cloning from the first editorstack in which every single new editor | ||
|
@@ -1942,7 +1952,17 @@ def replace(self): | |
"""Replace slot""" | ||
editorstack = self.get_current_editorstack() | ||
editorstack.find_widget.show_replace() | ||
|
||
|
||
def open_last_closed(self): | ||
""" Reopens the last closed tab.""" | ||
editorstack = self.get_current_editorstack() | ||
last_closed_files = editorstack.get_last_closed_files() | ||
if (len(last_closed_files) > 0): | ||
file_to_open = last_closed_files[0] | ||
last_closed_files.remove(file_to_open) | ||
editorstack.set_last_closed_files(last_closed_files) | ||
self.load(file_to_open) | ||
|
||
#------ Explorer widget | ||
def close_file_from_name(self, filename): | ||
"""Close file from its name""" | ||
|
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 couple of lines, and the import of
add_shortcut_to_tooltip
. They are not needed anymore.