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

Focus Atom application when text-synced from chrome browser #19

Merged
merged 1 commit into from
Jul 27, 2017
Merged
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
8 changes: 3 additions & 5 deletions lib/atomic-chrome.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{CompositeDisposable} = require 'atom'
{Server} = require 'ws'

WSHandler = require './ws-handler'

{Server} = require 'ws'
WSHandler = null # defer require till necessary
WS_PORT = 64292

module.exports = AtomicChrome =
activate: (state) ->
@wss = new Server({port: WS_PORT})

@wss.on 'connection', (ws) ->
WSHandler ?= require './ws-handler'
new WSHandler(ws)
@wss.on 'error', (err) ->
console.error(err) unless err.code == 'EADDRINUSE'
Expand Down
1 change: 1 addition & 0 deletions lib/ws-handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = class WSHandler

register: (data) ->
filepath = @getFile(data)
atom.focus() # activivate Atom application
atom.workspace.open(filepath).then (editor) =>
@initEditor(editor, data)

Expand Down