From d692e829b04508305bfd745ee034380508ecd071 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 9 Jun 2015 15:04:42 -0500 Subject: [PATCH] Editor: Open a new empty file after closing all files Fixes #2302 --- spyderlib/plugins/editor.py | 7 +++++-- spyderlib/widgets/editor.py | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spyderlib/plugins/editor.py b/spyderlib/plugins/editor.py index da294975ba3..e6b4cd8ebf9 100644 --- a/spyderlib/plugins/editor.py +++ b/spyderlib/plugins/editor.py @@ -1137,7 +1137,8 @@ def register_editorstack(self, editorstack): self.connect(editorstack, SIGNAL('zoom_out()'), lambda: self.zoom(-1)) self.connect(editorstack, SIGNAL('zoom_reset()'), lambda: self.zoom(0)) self.connect(editorstack, SIGNAL('close_file()'), self.close_file) - + self.connect(editorstack, SIGNAL('sig_new_file()'), self.new) + self.connect(editorstack, SIGNAL('close_file(QString,int)'), self.close_file_in_all_editorstacks) self.connect(editorstack, SIGNAL('file_saved(QString,int,QString)'), @@ -1733,7 +1734,9 @@ def close_file(self): """Close current file""" editorstack = self.get_current_editorstack() editorstack.close_file() - + if editorstack.get_stack_count() == 0: + self.new() + def close_all_files(self): """Close all opened scripts""" self.editorstacks[0].close_all_files() diff --git a/spyderlib/widgets/editor.py b/spyderlib/widgets/editor.py index e9ea41345b9..b606ed1aa1b 100644 --- a/spyderlib/widgets/editor.py +++ b/spyderlib/widgets/editor.py @@ -16,7 +16,7 @@ from spyderlib.qt import is_pyqt46 from spyderlib.qt.QtGui import (QVBoxLayout, QMessageBox, QMenu, QFont, QAction, QApplication, QWidget, QHBoxLayout, - QLabel, QKeySequence, QShortcut, QMainWindow, + QLabel, QKeySequence, QMainWindow, QSplitter, QListWidget, QListWidgetItem, QDialog, QLineEdit) from spyderlib.qt.QtCore import (SIGNAL, Qt, QFileInfo, QThread, QObject, @@ -25,7 +25,6 @@ import os import sys -import re import os.path as osp # Local imports @@ -640,7 +639,6 @@ def inspect_current_object(self): if self.introspector: editor = self.get_current_editor() position = editor.get_position('cursor') - finfo = self.get_current_finfo() self.inspector.switch_to_editor_source() self.introspector.show_object_info(position, auto=False) else: @@ -1184,8 +1182,10 @@ def close_file(self, index=None, force=False): if index < new_index: new_index -= 1 self.set_stack_index(new_index) + if self.get_stack_count() == 0: + self.emit(SIGNAL('sig_new_file()')) return is_ok - + def close_all_files(self): """Close all opened scripts""" while self.close_file():