Skip to content

Commit ca880cc

Browse files
committed
Fix document changes version bug
1 parent bcca365 commit ca880cc

1 file changed

Lines changed: 13 additions & 18 deletions

File tree

src/StaticLS/ProtoLSP.hs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module StaticLS.ProtoLSP (
2727
)
2828
where
2929

30+
import Data.Map qualified as Map
3031
import Control.Monad ((<=<))
3132
import Control.Monad.Catch
3233
import Data.Aeson qualified as Aeson
@@ -154,25 +155,19 @@ editToProto rope edit =
154155
changeToProto rope <$> Edit.getChanges edit
155156

156157
-- TODO: convert fsEdits
158+
157159
sourceEditToProto :: SourceEdit -> StaticLsM LSP.WorkspaceEdit
158-
sourceEditToProto SourceEdit {fileEdits} = do
159-
documentChanges <- for (HashMap.toList fileEdits) \(path, edit) -> do
160-
rope <- IDE.Monad.getSourceRope path
161-
pure
162-
LSP.TextDocumentEdit
163-
{ _textDocument =
164-
LSP.OptionalVersionedTextDocumentIdentifier
165-
{ _uri = absPathToUri path
166-
, _version = LSP.InR LSP.Null
167-
}
168-
, _edits = LSP.InL <$> editToProto rope edit
169-
}
170-
pure
171-
LSP.WorkspaceEdit
172-
{ _changes = Nothing
173-
, _documentChanges = Just (fmap LSP.InL documentChanges)
174-
, _changeAnnotations = Nothing
175-
}
160+
sourceEditToProto SourceEdit{ fileEdits } = do
161+
changesKVs <- for (HashMap.toList fileEdits) $ \(path, edit) -> do
162+
rope <- IDE.Monad.getSourceRope path
163+
let edits = editToProto rope edit
164+
pure (absPathToUri path, edits)
165+
166+
pure LSP.WorkspaceEdit
167+
{ _changes = Just (Map.fromList changesKVs)
168+
, _documentChanges = Nothing
169+
, _changeAnnotations = Nothing
170+
}
176171

177172
assistToCodeAction :: Assist -> StaticLsM LSP.CodeAction
178173
assistToCodeAction Assist {label, sourceEdit} = do

0 commit comments

Comments
 (0)