From fc5a30c00538a4d45955e138c0d35f72c8c2a58f Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Fri, 29 May 2015 08:41:07 -0400 Subject: [PATCH 1/5] add fs-plus dependency; fix edit --- lib/ex.coffee | 10 +++++----- package.json | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index 21f5037..5ad6be5 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,6 +1,6 @@ path = require 'path' CommandError = require './command-error' -fs = require 'fs' +fs = require 'fs-plus' trySave = (func) -> deferred = Promise.defer() @@ -102,10 +102,10 @@ class Ex filePath = filePath.trim() if filePath.indexOf(' ') isnt -1 throw new CommandError('Only one file name allowed') - buffer = atom.workspace.getActiveTextEditor().buffer - filePath = buffer.getPath() if filePath is '' - buffer.setPath(getFullPath(filePath)) - buffer.load() + + filePath = fs.normalize filePath + atom.workspace.open(filePath) + e: (args...) => @edit(args...) diff --git a/package.json b/package.json index 3364f3e..6960bb2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "underscore-plus": "1.x", "event-kit": "^0.7.2", "space-pen": "^5.1.1", - "atom-space-pen-views": "^2.0.4" + "atom-space-pen-views": "^2.0.4", + "fs-plus": "^2.2.8" }, "consumedServices": { "vim-mode": { From 2702ba4d793d186a77488d6fb9fec5f1e9038cba Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Fri, 29 May 2015 08:46:53 -0400 Subject: [PATCH 2/5] organize imports --- lib/ex.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index 5ad6be5..a41a846 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -1,6 +1,7 @@ path = require 'path' +fs = require 'fs-plus' + CommandError = require './command-error' -fs = require 'fs-plus' trySave = (func) -> deferred = Promise.defer() @@ -103,7 +104,7 @@ class Ex if filePath.indexOf(' ') isnt -1 throw new CommandError('Only one file name allowed') - filePath = fs.normalize filePath + filePath = getFullPath filePath atom.workspace.open(filePath) From 394dd1dffa4d3b202d9e220db7310e8a45cfcb21 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Fri, 29 May 2015 08:51:32 -0400 Subject: [PATCH 3/5] move fs.normalize call to getFullPath --- lib/ex.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ex.coffee b/lib/ex.coffee index a41a846..7b963ea 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -37,6 +37,7 @@ saveAs = (filePath) -> fs.writeFileSync(filePath, editor.getText()) getFullPath = (filePath) -> + filePath = fs.normalize filePath return filePath if path.isAbsolute(filePath) return path.join(atom.project.getPath(), filePath) From 6d723b8a4ada9f99491ff4679928a54d5133759b Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Fri, 29 May 2015 15:43:44 -0400 Subject: [PATCH 4/5] restore edit behaviour: open in current buffer --- lib/ex.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index 7b963ea..eff71bc 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -104,10 +104,10 @@ class Ex filePath = filePath.trim() if filePath.indexOf(' ') isnt -1 throw new CommandError('Only one file name allowed') - - filePath = getFullPath filePath - atom.workspace.open(filePath) - + buffer = atom.workspace.getActiveTextEditor().buffer + filePath = buffer.getPath() if filePath is '' + buffer.setPath(getFullPath(filePath)) + buffer.load() e: (args...) => @edit(args...) From 69005eb880eccf59e154fcad20e777e67d76abe6 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Fri, 29 May 2015 15:44:36 -0400 Subject: [PATCH 5/5] fix deprecation call: atom.project.getPath --- lib/ex.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ex.coffee b/lib/ex.coffee index eff71bc..a5d7ff5 100644 --- a/lib/ex.coffee +++ b/lib/ex.coffee @@ -39,7 +39,7 @@ saveAs = (filePath) -> getFullPath = (filePath) -> filePath = fs.normalize filePath return filePath if path.isAbsolute(filePath) - return path.join(atom.project.getPath(), filePath) + return path.join(atom.project.getPaths()[0], filePath) replaceGroups = (groups, replString) -> arr = replString.split('')