-
-
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
7c845ae
added open last closed tab option
thewhitetulip 8668d14
Changed shortcut of open last closed tab
thewhitetulip 159c282
unintened change reverted
thewhitetulip 268a5f4
Made small case
thewhitetulip 468c828
review issues fixed
thewhitetulip 7514107
fixed alignment in list
mariacamilarg e33369b
mess up an indentation, now is fixed
mariacamilarg ad2e96f
now open last closed tabs is working
mariacamilarg 557e350
checkpoint so I can temporarily switch to another issue
mariacamilarg 7a39e14
the signal is emitted but I am not sure how to catch it
mariacamilarg cfaddd0
everything works now, signals are not needed
mariacamilarg 98c85a5
forgot to erase last_closed_files from main
mariacamilarg c127d8e
merge with 3.x to update tests dependencies
mariacamilarg 3db633a
removing slot annotation
mariacamilarg 8140e17
merge to include 3.x updates in tests
mariacamilarg ff635d9
PR comments addressed
mariacamilarg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
QWidget) | ||
|
||
# Local imports | ||
from spyder.config.main import CONF | ||
from spyder.config.base import _, DEBUG, STDERR, STDOUT | ||
from spyder.config.gui import (config_shortcut, fixed_shortcut, | ||
RUN_CELL_SHORTCUT, | ||
|
@@ -423,6 +424,9 @@ def __init__(self, parent, actions): | |
# Local shortcuts | ||
self.shortcuts = self.create_shortcuts() | ||
|
||
#For opening last closed tabs | ||
self.last_closed_files = CONF.get('editor', 'last_closed_files') | ||
|
||
def create_shortcuts(self): | ||
"""Create local shortcuts""" | ||
# --- Configurable shortcuts | ||
|
@@ -1168,6 +1172,9 @@ def close_file(self, index=None, force=False): | |
new_index -= 1 | ||
self.set_stack_index(new_index) | ||
|
||
self.add_last_closed_file(finfo.filename) | ||
print("ultimosss:", self.last_closed_files) | ||
|
||
if self.get_stack_count() == 0 and self.create_new_file_if_empty: | ||
self.sig_new_file[()].emit() | ||
return False | ||
|
@@ -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""" | ||
if fname is None: | ||
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. Is this if really needed? |
||
return | ||
if fname in self.last_closed_files: | ||
self.last_closed_files.remove(fname) | ||
self.last_closed_files.insert(0, fname) | ||
if len(self.last_closed_files) > CONF.get('editor','max_recent_files'): | ||
self.last_closed_files.pop(-1) | ||
CONF.set('editor', 'last_closed_files', self.last_closed_files) | ||
print("last closed files:", [rf.split("/")[-1] for rf in self.last_closed_files]) | ||
|
||
#------ Save | ||
def save_if_changed(self, cancelable=False, index=None): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Docstrings are sentences so a
.
is needed at the end :-)"""Add to last closed file list."""