-
Notifications
You must be signed in to change notification settings - Fork 93
Avoid couple partial functions in lsp-test #546
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,9 +187,9 @@ data SessionState = SessionState | |
, vfs :: !VFS | ||
, curDiagnostics :: !(Map.Map NormalizedUri [Diagnostic]) | ||
, overridingTimeout :: !Bool | ||
, lastReceivedMessage :: !(Maybe FromServerMessage) | ||
-- ^ The last received message from the server. | ||
-- Used for providing exception information | ||
, lastReceivedMessage :: !(Maybe FromServerMessage) | ||
, curDynCaps :: !(Map.Map T.Text SomeRegistration) | ||
-- ^ The capabilities that the server has dynamically registered with us so | ||
-- far | ||
|
@@ -250,7 +250,7 @@ runSessionMonad context state (Session session) = runReaderT (runStateT conduit | |
curId <- getCurTimeoutId | ||
case msg of | ||
ServerMessage sMsg -> yield sMsg | ||
TimeoutMessage tId -> when (curId == tId) $ lastReceivedMessage <$> get >>= throw . Timeout | ||
TimeoutMessage tId -> when (curId == tId) $ get >>= throw . Timeout . lastReceivedMessage | ||
|
||
-- | An internal version of 'runSession' that allows for a custom handler to listen to the server. | ||
-- It also does not automatically send initialize and exit messages. | ||
|
@@ -468,11 +468,11 @@ updateState (FromServerMess SMethod_WorkspaceApplyEdit r) = do | |
|
||
textDocumentEdits uri edits = do | ||
vers <- textDocumentVersions uri | ||
pure $ map (\(v, e) -> TextDocumentEdit (review _versionedTextDocumentIdentifier v) [InL e]) $ zip vers edits | ||
pure $ zipWith (\v e -> TextDocumentEdit (review _versionedTextDocumentIdentifier v) [InL e]) vers edits | ||
|
||
getChangeParams uri edits = do | ||
edits <- textDocumentEdits uri (reverse edits) | ||
pure $ catMaybes $ map getParamsFromTextDocumentEdit edits | ||
pure $ mapMaybe getParamsFromTextDocumentEdit edits | ||
|
||
mergeParams :: [DidChangeTextDocumentParams] -> DidChangeTextDocumentParams | ||
mergeParams params = let events = concat (toList (map (toList . (^. L.contentChanges)) params)) | ||
|
@@ -513,7 +513,7 @@ logMsg t msg = do | |
shouldColor <- asks $ logColor . config | ||
liftIO $ when shouldLog $ do | ||
when shouldColor $ setSGR [SetColor Foreground Dull color] | ||
putStrLn $ arrow ++ showPretty msg | ||
B.putStrLn $ arrow <> encodePretty msg | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems pointless to convert pretty-printed json bytestring to String just to print it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea, but seems sensible |
||
when shouldColor $ setSGR [Reset] | ||
|
||
where arrow | ||
|
@@ -523,4 +523,3 @@ logMsg t msg = do | |
| t == LogServer = Magenta | ||
| otherwise = Cyan | ||
|
||
showPretty = B.unpack . encodePretty |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateRequestMap returns Nothing when request with given LspId is already in it.
I don't see how it makes sense to crash in such cases as opposed to returning the origial map unmodified. Similarly in the file below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's quite bad: that means we've somehow reused an ID which means stuff will break. So I think this probably should throw, but maybe not by using
fromJust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I'll play around with it locally to see if I can reproduce the me play around with how this works to see if I can reproduce the
Timed out waiting to receive a message from the server.
locally and then get back to this or close this.