-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Update version while editing to conform lsp spec #3566
Conversation
I confess I'm very hazy about how file versions are supposed to work at all, and the LSP spec doesn't really tell you. But shouldn't there be somewhere in the code where you bump the version? |
I've consulted with the client developer, see details here helix-editor/helix#6543 (comment) |
Okay, sounds good. Maybe we should write something about how to use it? Or audit the other uses now you know what we should be doing? |
I think we can add version checking in |
Ideally, I want we can track version info in the plugin descriptor, then we can remove some parameters passing, but it's not easy. |
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.
Okay, I think I'm convinced that this is the right thing to do. It would be nice to write down the logic somewhere, I'm not sure where. Alternatively, if we go the route of passing the VTDI everywhere instead of reconstructing it, we could add a hlint rule that warns if people use the constructor?
@@ -161,16 +161,16 @@ diffTextEdit fText f2Text withDeletions = J.List r | |||
|
|||
|
|||
-- | A pure version of 'diffText' for testing | |||
diffText' :: Bool -> (Uri,T.Text) -> T.Text -> WithDeletions -> WorkspaceEdit | |||
diffText' supports (f,fText) f2Text withDeletions = | |||
diffText' :: Bool -> (Uri,T.Text) -> T.Text -> WithDeletions -> TextDocumentVersion -> WorkspaceEdit |
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.
diffText' :: Bool -> (Uri,T.Text) -> T.Text -> WithDeletions -> TextDocumentVersion -> WorkspaceEdit | |
diffText' :: Bool -> (VersionedTextDocmentIdentifier, T.Text) -> T.Text -> WithDeletions -> TextDocumentVersion -> WorkspaceEdit |
what about something like this? Since really the idea is that we want to use the same identifier as the one we were given - at the moment we're taking the parts and then putting it back together, we could just take the identifier.
@@ -38,6 +38,7 @@ data AddMinimalMethodsParams = AddMinimalMethodsParams | |||
, methodGroup :: List (T.Text, T.Text) | |||
-- ^ (name text, signature text) | |||
, withSig :: Bool | |||
, textVersion :: TextDocumentVersion |
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.
similarly, replace the uri
field with a VerisonedTextDocumentIdentifier
@@ -451,8 +455,8 @@ codeActionProvider ideState pluginId (CodeActionParams _ _ documentId _ context) | |||
|
|||
-- | Convert a hlint diagnostic into an apply and an ignore code action | |||
-- if applicable | |||
diagnosticToCodeActions :: DynFlags -> T.Text -> PluginId -> TextDocumentIdentifier -> LSP.Diagnostic -> [LSP.CodeAction] | |||
diagnosticToCodeActions dynFlags fileContents pluginId documentId diagnostic | |||
diagnosticToCodeActions :: DynFlags -> T.Text -> PluginId -> TextDocumentIdentifier -> TextDocumentVersion -> LSP.Diagnostic -> [LSP.CodeAction] |
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.
diagnosticToCodeActions :: DynFlags -> T.Text -> PluginId -> TextDocumentIdentifier -> TextDocumentVersion -> LSP.Diagnostic -> [LSP.CodeAction] | |
diagnosticToCodeActions :: DynFlags -> T.Text -> PluginId -> VersionedTextDocumentIdentifier -> LSP.Diagnostic -> [LSP.CodeAction] |
@@ -511,13 +515,13 @@ mkSuppressHintTextEdits dynFlags fileContents hint = | |||
combinedTextEdit : lineSplitTextEditList | |||
-- --------------------------------------------------------------------- | |||
|
|||
applyAllCmd :: Recorder (WithPriority Log) -> CommandFunction IdeState Uri | |||
applyAllCmd recorder ide uri = do | |||
applyAllCmd :: Recorder (WithPriority Log) -> CommandFunction IdeState (Uri, TextDocumentVersion) |
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.
applyAllCmd :: Recorder (WithPriority Log) -> CommandFunction IdeState (Uri, TextDocumentVersion) | |
applyAllCmd :: Recorder (WithPriority Log) -> CommandFunction IdeState VersionedTextDocumentIdentifier |
-- | There can be more than one hint suggested at the same position, so HintTitle is used to distinguish between them. | ||
, hintTitle :: HintTitle | ||
, hintTitle :: HintTitle | ||
, textVersion :: TextDocumentVersion |
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.
etc.
logWith recorder Debug $ LogApplying file res | ||
case res of | ||
Left err -> pure $ Left (responseError (T.pack $ "hlint:applyOne: " ++ show err)) | ||
Right fs -> do | ||
_ <- sendRequest SWorkspaceApplyEdit (ApplyWorkspaceEditParams Nothing fs) (\_ -> pure ()) | ||
pure $ Right Null | ||
|
||
applyHint :: Recorder (WithPriority Log) -> IdeState -> NormalizedFilePath -> Maybe OneHint -> IO (Either String WorkspaceEdit) | ||
applyHint recorder ide nfp mhint = | ||
applyHint :: Recorder (WithPriority Log) -> IdeState -> NormalizedFilePath -> Maybe OneHint -> TextDocumentVersion -> IO (Either String WorkspaceEdit) |
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.
bit akward her because we've got a NFP here, but maybe we could get away with passing the VTDI instead?
I can report that the PR in this form fixes code actions in helix for me. @July541 Just so you know, I am trying to work on this here at zurihac. Will report back once I have made progress. |
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.
LGTM foSplice Plugin 👍
Fix #3547 and #3498.
Tests is broken due to
lsp-test
's limitation.