Skip to content

Commit

Permalink
Merge pull request #54 from idris-hackers/issue-51
Browse files Browse the repository at this point in the history
Restart the idris compiler after every commmand if it was killed
  • Loading branch information
archaeron committed Sep 18, 2015
2 parents 7369da9 + c8d9b8e commit 1c306ee
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added

- Restart the idris compiler after every commmand if it was killed [#54](https://github.com/idris-hackers/atom-language-idris/pull/54)
- added the ability to style all the idris-panels

### Fixed
Expand Down
4 changes: 4 additions & 0 deletions lib/idris-controller.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IdrisController
'language-idris:proof-search': @runCommand @doProofSearch
'language-idris:typecheck': @runCommand @typecheckFile
'language-idris:print-definition': @runCommand @printDefinition
'language-idris:stop-compiler': @stopCompiler

isIdrisFile: (uri) ->
uri?.match? /\.idr$/
Expand All @@ -46,6 +47,9 @@ class IdrisController
@messages.attach()
@messages.hide()

stopCompiler: =>
@model?.stop()

runCommand:
(command) =>
(args) =>
Expand Down
36 changes: 21 additions & 15 deletions lib/idris-ide-mode.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ class IdrisIdeMode extends EventEmitter
buffer: ''
idrisBuffers: 0

constructor: ->
pathToIdris = atom.config.get("language-idris.pathToIdris")
@process = spawn pathToIdris, ['--ide-mode']
@process.on 'error', @error
@process.on 'exit', @exited
@process.on 'close', @exited
@process.on 'disconnect', @exited
start: ->
if (not @process?) || @process.killed
pathToIdris = atom.config.get("language-idris.pathToIdris")
@process = spawn pathToIdris, ['--ide-mode']
@process.on 'error', @error
@process.on 'exit', @exited
@process.on 'close', @exited
@process.on 'disconnect', @exited

@process.stdout.setEncoding('utf8').on 'data', @stdout
@process.stdout.setEncoding('utf8').on 'data', @stdout

send: (cmd) ->
Logger.logOutgoingCommand cmd
Expand All @@ -38,13 +39,18 @@ class IdrisIdeMode extends EventEmitter
atom.notifications.addError e.short, detail: e.long

exited: (code, signal) ->
short = "The idris compiler was closed or crashed"
long =
if signal
"It was closed with the signal: #{signal}"
else
"It (probably) crashed with the error code: #{code}"
atom.notifications.addError short, detail: long
if signal == "SIGTERM"
short = "The idris compiler was closed"
long = "You stopped the compiler"
atom.notifications.addInfo short, detail: long
else
short = "The idris compiler was closed or crashed"
long =
if signal
"It was closed with the signal: #{signal}"
else
"It (probably) crashed with the error code: #{code}"
atom.notifications.addError short, detail: long

running: ->
!!@process
Expand Down
1 change: 1 addition & 0 deletions lib/idris-model.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class IdrisModel
if !@ideModeRef
@ideModeRef = new IdrisIdeMode
@ideModeRef.on 'message', @handleCommand
@ideModeRef.start()
@ideModeRef

stop: ->
Expand Down

0 comments on commit 1c306ee

Please sign in to comment.