Skip to content

Commit

Permalink
Editor: Open a new empty file after closing all files
Browse files Browse the repository at this point in the history
Fixes #2302
  • Loading branch information
ccordoba12 committed Jun 9, 2015
1 parent 08cfe5e commit d692e82
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions spyderlib/plugins/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)'),
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions spyderlib/widgets/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -25,7 +25,6 @@

import os
import sys
import re
import os.path as osp

# Local imports
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit d692e82

Please sign in to comment.