From e8b0e8957f84d918747320d47abaf0d4416b2eba Mon Sep 17 00:00:00 2001 From: Nicolas Gagliani Date: Sat, 29 Aug 2015 15:27:32 +0200 Subject: [PATCH 1/4] restart the idris compiler after every commmand if it was killed --- lib/idris-ide-mode.coffee | 17 +++++++++-------- lib/idris-model.coffee | 1 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/idris-ide-mode.coffee b/lib/idris-ide-mode.coffee index b992178..0dca2e6 100644 --- a/lib/idris-ide-mode.coffee +++ b/lib/idris-ide-mode.coffee @@ -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 diff --git a/lib/idris-model.coffee b/lib/idris-model.coffee index 7e259d0..cbb8fc2 100644 --- a/lib/idris-model.coffee +++ b/lib/idris-model.coffee @@ -12,6 +12,7 @@ class IdrisModel if !@ideModeRef @ideModeRef = new IdrisIdeMode @ideModeRef.on 'message', @handleCommand + @ideModeRef.start() @ideModeRef stop: -> From a0175f89739e8dd54944316a5e76f5bb159982dd Mon Sep 17 00:00:00 2001 From: Nicolas Gagliani Date: Sat, 29 Aug 2015 15:36:56 +0200 Subject: [PATCH 2/4] ability to stop the compiler with a command --- lib/idris-controller.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/idris-controller.coffee b/lib/idris-controller.coffee index 7934ac7..6583bb8 100644 --- a/lib/idris-controller.coffee +++ b/lib/idris-controller.coffee @@ -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$/ @@ -46,6 +47,9 @@ class IdrisController @messages.attach() @messages.hide() + stopCompiler: => + @model?.stop() + runCommand: (command) => (args) => From 11f2edf93d4dcc9fbb1d3d5dcd3b858e9bd5b81b Mon Sep 17 00:00:00 2001 From: Nicolas Gagliani Date: Wed, 16 Sep 2015 17:32:19 +0200 Subject: [PATCH 3/4] less dire error message if the user stopped the compiler manually --- lib/idris-ide-mode.coffee | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/idris-ide-mode.coffee b/lib/idris-ide-mode.coffee index 0dca2e6..bd32ed3 100644 --- a/lib/idris-ide-mode.coffee +++ b/lib/idris-ide-mode.coffee @@ -39,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 From efbce994236f7d9f8ada9026bbde7c51409a5313 Mon Sep 17 00:00:00 2001 From: Nicolas Gagliani Date: Sat, 19 Sep 2015 01:12:43 +0200 Subject: [PATCH 4/4] updated the changelog for #54 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 228a49d..5790307 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Added +- Restart the idris compiler after every commmand if it was killed [#54](https://github.com/idris-hackers/atom-language-idris/pull/54) + ### Fixed ## v0.2.4