From 4ee534218e5a400804ee70d33f237ea87a694876 Mon Sep 17 00:00:00 2001 From: Rafael Laverde Date: Mon, 23 Jan 2017 12:24:11 -0500 Subject: [PATCH] Allow new files to be saved before modifing them. --- spyder/plugins/editor.py | 2 +- spyder/widgets/editor.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/spyder/plugins/editor.py b/spyder/plugins/editor.py index e6d8670dab7..1c6ec206418 100644 --- a/spyder/plugins/editor.py +++ b/spyder/plugins/editor.py @@ -1477,7 +1477,7 @@ def refresh_file_dependent_actions(self): def refresh_save_all_action(self): """Enable 'Save All' if there are files to be saved""" editorstack = self.get_current_editorstack() - state = any(finfo.editor.document().isModified() + state = any(finfo.editor.document().isModified() or finfo.newly_created for finfo in editorstack.data) self.save_all_action.setEnabled(state) diff --git a/spyder/widgets/editor.py b/spyder/widgets/editor.py index dbc30eed3e1..87fe5eb9f43 100644 --- a/spyder/widgets/editor.py +++ b/spyder/widgets/editor.py @@ -1301,7 +1301,8 @@ def save(self, index=None, force=False): index = self.get_stack_index() finfo = self.data[index] - if not finfo.editor.document().isModified() and not force: + if not (finfo.editor.document().isModified() or + finfo.newly_created) and not force: return True if not osp.isfile(finfo.filename) and not force: # File has not been saved yet @@ -1662,7 +1663,7 @@ def modification_changed(self, state=None, index=None, editor_id=None): return finfo = self.data[index] if state is None: - state = finfo.editor.document().isModified() + state = finfo.editor.document().isModified() or finfo.newly_created self.set_stack_title(index, state) # Toggle save/save all actions state self.save_action.setEnabled(state)