diff --git a/lib/idris-controller.coffee b/lib/idris-controller.coffee index ad16a17..df2cd46 100644 --- a/lib/idris-controller.coffee +++ b/lib/idris-controller.coffee @@ -114,6 +114,7 @@ class IdrisController getDocsForWord: ({ target }) => word = Symbol.serializeWord @getWordUnderCursor(target) + uri = target.model.getURI() successHandler = ({ responseType, msg }) => [type, highlightingInfo] = msg @@ -128,7 +129,10 @@ class IdrisController @messages.add informationView @model - .docsFor word + .load uri + .filter ({ responseType }) -> responseType == 'return' + .flatMap => @model.docsFor word + .catch (e) => @model.docsFor word .subscribe successHandler, @displayErrors getTypeForWord: ({ target }) => @@ -348,6 +352,7 @@ class IdrisController printDefinition: ({ target }) => word = Symbol.serializeWord @getWordUnderCursor(target) + uri = target.model.getURI() successHandler = ({ responseType, msg }) => [type, highlightingInfo] = msg @@ -362,7 +367,10 @@ class IdrisController @messages.add informationView @model - .printDefinition word + .load uri + .filter ({ responseType }) -> responseType == 'return' + .flatMap => @model.printDefinition word + .catch (e) => @model.printDefinition word .subscribe successHandler, @displayErrors openREPL: ({ target }) => diff --git a/lib/idris-model.coffee b/lib/idris-model.coffee index d4fe96e..b087d95 100644 --- a/lib/idris-model.coffee +++ b/lib/idris-model.coffee @@ -13,7 +13,11 @@ class IdrisModel oldCompilerOptions: { } ideMode: (compilerOptions) -> - if !@ideModeRef || !JS.objectEqual(@oldCompilerOptions, compilerOptions) + if @ideModeRef && !JS.objectEqual(@oldCompilerOptions, compilerOptions) + @ideModeRef.process.removeAllListeners() + @ideModeRef.stop() + @ideModeRef = null + if !@ideModeRef @ideModeRef = new IdrisIdeMode @ideModeRef.on 'message', @handleCommand @ideModeRef.start compilerOptions