Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 47 #71

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions lib/open-in-browser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,28 @@ module.exports =
@subscriptions.add atom.commands.add '.tree-view .file',
'open-in-browser:open-tree-view', @openTreeView.bind(this)

getFilePath: -> atom.workspace.getActiveTextEditor().getPath()
getFilePath: ->
new Promise (resolve, reject) ->
if atom.workspace.hasActiveTextEditor
resolve atom.workspace.getActiveTextEditor().getPath()
else
reject Error 'Active pane item is not a text editor.'

openEditor: ->
@open @getFilePath()
@getFilePath()
.then (result) =>
if result? then @open result else Error 'Path undefined for editor content. (Has it been saved?)'
.catch (error) => @report error

openTreeView: ({target}) ->
@open target.dataset.path

open: (filePath) ->
opn(filePath).catch (error) ->
atom.notifications.addError error.toString(), detail: error.stack or '', dismissable: true
console.error error
opn(filePath)

report: (error) ->
atom.notifications.addError error.toString(), detail: error.stack or '', dismissable: true
console.error error

deactivate: ->
@subscriptions?.dispose()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "open-in-browser",
"main": "./lib/open-in-browser",
"version": "0.5.2",
"version": "0.5.3",
"description": "Simple Package to open file in default application",
"repository": "https://github.com/magbicaleman/open-in-browser",
"license": "MIT",
Expand Down