From 2b9b2f26e5aa2c5da7929737271eb305904cbb76 Mon Sep 17 00:00:00 2001 From: jazzpi Date: Wed, 10 Aug 2016 01:29:21 +0200 Subject: [PATCH] Update editor when saving a new file with `:w` or `:saveas` Fixes #156 --- lib/ex.coffee | 2 +- spec/ex-commands-spec.coffee | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index 21e4add..0f7fee9 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -222,7 +222,7 @@ class Ex if not saved and fullPath? if not force and fs.existsSync(fullPath) throw new CommandError("File exists (add ! to override)") - if saveas + if saveas or editor.getFileName() == null editor = atom.workspace.getActiveTextEditor() trySave(-> editor.saveAs(fullPath, editor)).then(deferred.resolve) else diff --git a/spec/ex-commands-spec.coffee b/spec/ex-commands-spec.coffee index 08237e3..1b1178e 100644 --- a/spec/ex-commands-spec.coffee +++ b/spec/ex-commands-spec.coffee @@ -79,6 +79,7 @@ describe "the commands", -> submitNormalModeInputText('write') expect(fs.existsSync(filePath)).toBe(true) expect(fs.readFileSync(filePath, 'utf-8')).toEqual('abc\ndef') + expect(editor.isModified()).toBe(false) it "saves when a path is specified in the save dialog", -> spyOn(atom, 'showSaveDialogSync').andReturn(undefined)