intero 0.1.27 → 0.1.28
raw patch · 4 files changed
+45/−31 lines, 4 files
Files
- elisp/intero.el +31/−25
- intero.cabal +5/−2
- src/InteractiveUI.hs +7/−2
- src/test/Main.hs +2/−2
elisp/intero.el view
@@ -2061,33 +2061,39 @@ (error "Intero process is not running: run M-x intero-restart to start it")))) (defun intero-network-call-sentinel (process event)- (with-current-buffer (process-buffer process)- (if (string= "open\n" event)- (progn- (when intero-debug (message "Connected to service, sending %S" intero-async-network-cmd))- (setq intero-async-network-connected t)- (if intero-async-network-cmd- (process-send-string process (concat intero-async-network-cmd "\n"))- (delete-process process)))- (progn- (if intero-async-network-connected+ (let ((buf (process-buffer process)))+ (cl-flet ((cleanup ()+ (delete-process process)+ (kill-buffer buf)))+ (if (string= "open\n" event)+ (let ((cmd+ (with-current-buffer buf+ (when intero-debug (message "Connected to service, sending %S" intero-async-network-cmd))+ (setq intero-async-network-connected t)+ (and intero-async-network-cmd+ (concat intero-async-network-cmd "\n")))))+ (if cmd+ (process-send-string process cmd)+ (cleanup)))+ (with-current-buffer buf+ (if intero-async-network-connected+ (when intero-async-network-callback+ (when intero-debug (message "Calling callback with %S" (buffer-string)))+ (funcall intero-async-network-callback+ intero-async-network-state+ (buffer-string)))+ ;; We didn't successfully connect, so let's fallback to the+ ;; process pipe. (when intero-async-network-callback- (when intero-debug (message "Calling callback with %S" (buffer-string)))- (funcall intero-async-network-callback- intero-async-network-state- (buffer-string)))- ;; We didn't successfully connect, so let's fallback to the- ;; process pipe.- (when intero-async-network-callback- (when intero-debug (message "Failed to connect, falling back ... "))- (setq intero-async-network-callback nil)- (intero-async-call- intero-async-network-worker- intero-async-network-cmd- intero-async-network-state- intero-async-network-callback)))+ (when intero-debug (message "Failed to connect, falling back ... "))+ (setq intero-async-network-callback nil)+ (intero-async-call+ intero-async-network-worker+ intero-async-network-cmd+ intero-async-network-state+ intero-async-network-callback)))) ;; In any case we clean up the connection.- (delete-process process)))))+ (cleanup))))) (defun intero-async-call (worker cmd &optional state callback) "Send WORKER the command string CMD.
intero.cabal view
@@ -1,7 +1,7 @@ name: intero version:- 0.1.27+ 0.1.28 synopsis: Complete interactive development program for Haskell license:@@ -65,7 +65,6 @@ GhciTypes GhciInfo GhciFind- Completion Paths_intero build-depends: base < 5,@@ -85,6 +84,10 @@ network, random, mtl++ if impl(ghc>=8.2.2)+ other-modules:+ Completion if impl(ghc>=8.0.1) build-depends:
src/InteractiveUI.hs view
@@ -51,7 +51,9 @@ import GhciMonad hiding ( args, runStmt ) import GhciTags import Debugger+#if __GLASGOW_HASKELL__ >= 802 import qualified Completion+#endif -- The GHC interface import Data.IORef@@ -125,7 +127,7 @@ import qualified Data.ByteString.Char8 as BS import Data.Char import Data.Function-import Data.IORef ( IORef, readIORef, writeIORef )+ import Data.List ( find, group, intercalate, intersperse, isPrefixOf, nub, partition, sort, sortBy) import Data.Maybe@@ -301,6 +303,7 @@ where lifted m = \str -> lift (m stdout str) fillCmd :: Handle -> String -> GHCi ()+#if __GLASGOW_HASKELL__ >= 802 fillCmd h = withFillInput (\fp line col -> do@@ -338,6 +341,9 @@ liftIO (hPutStrLn h (Completion.substitutionString sub))) subs)+#else+fillCmd _ = withFillInput (\_ _ _ -> pure ())+#endif withFillInput :: (FilePath -> Int -> Int -> GHCi ()) -> String -> GHCi () withFillInput cont input =@@ -352,7 +358,6 @@ , ("uses", findAllUses) , ("loc-at", locationAt) , ("complete-at", completeAt)- , ("fill",fillCmd) ] -- We initialize readline (in the interactiveUI function) to use
src/test/Main.hs view
@@ -57,7 +57,7 @@ "https://github.com/commercialhaskell/intero/issues/28" (eval ":type-at"- "\n<no location info>: Expected a span: \"<module-name/filepath>\" <start line> <start column> <end line> <end column> \"<sample string>\"\n"))+ "<no location info>: Expected a span: \"<module-name/filepath>\" <start line> <start column> <end line> <end column> \"<sample string>\"\n")) -- | Basic commands that should work out of the box. basics :: Spec@@ -521,7 +521,7 @@ -> Expectation eval send recv = do reply <- withIntero [] (\_ repl -> repl send)- shouldBe reply recv+ shouldBe (unlines (filter (not . null) (lines reply))) recv -- | Launch an interactive intero process. Creates a temporary -- directory in which the computation can work.