mirror of
https://github.com/slap-editor/slap.git
synced 2024-09-11 04:45:47 +03:00
fix(open): closes #243
This commit is contained in:
parent
708f5ba74c
commit
829b3347b8
@ -53,18 +53,19 @@ Slap.prototype.open = Promise.method(function (filePath, current) {
|
||||
var self = this;
|
||||
|
||||
var pane = self.paneForPath(filePath);
|
||||
pane = pane || new Pane({parent: self});
|
||||
if (fs.lstatSync(filePath).isDirectory()) { // check if filePath is a directory
|
||||
self.fileBrowser.refresh(filePath, _.noop); // open the directory on the sidebar
|
||||
return;
|
||||
}
|
||||
return pane.editor.open(filePath)
|
||||
return Promise.resolve(pane)
|
||||
.then(function () {
|
||||
if (pane) return;
|
||||
if (fs.lstatSync(filePath).isDirectory()) throw _.merge(new Error('EISDIR: illegal operation on a directory, read'), {cause: {code: 'EISDIR'}});
|
||||
pane = new Pane({parent: self});
|
||||
return pane.editor.open(filePath);
|
||||
})
|
||||
.then(function () {
|
||||
if (current) pane.setCurrent();
|
||||
return pane;
|
||||
})
|
||||
.catch(function (err) {
|
||||
pane.close();
|
||||
if (pane) pane.close();
|
||||
switch ((err.cause || err).code) {
|
||||
case 'EACCES':
|
||||
self.header.message(err.message, 'error');
|
||||
|
Loading…
Reference in New Issue
Block a user