Skip to content

Commit ea4f26c

Browse files
committed
Add fix
1 parent 96aaa16 commit ea4f26c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lsp-test/src/Language/LSP/Test/Session.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,10 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
354354
allChangeParams <- case r ^. params . edit . documentChanges of
355355
Just (List cs) -> do
356356
mapM_ (checkIfNeedsOpened . documentChangeUri) cs
357-
return $ mapMaybe getParamsFromDocumentChange cs
357+
-- replace the user provided version numbers with the VFS ones + 1
358+
-- (technically we should check that the user versions match the VFS ones)
359+
cs' <- traverseOf (traverse . _InL . textDocument) bumpNewestVersion cs
360+
return $ mapMaybe getParamsFromDocumentChange cs'
358361
-- Then fall back to the changes field
359362
Nothing -> case r ^. params . edit . changes of
360363
Just cs -> do
@@ -401,7 +404,7 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
401404
return $ s { vfs = newVFS }
402405

403406
getParamsFromTextDocumentEdit :: TextDocumentEdit -> DidChangeTextDocumentParams
404-
getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) =
407+
getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) = do
405408
DidChangeTextDocumentParams docId (List $ map editToChangeEvent edits)
406409

407410
editToChangeEvent :: TextEdit |? AnnotatedTextEdit -> TextDocumentContentChangeEvent
@@ -412,6 +415,8 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
412415
getParamsFromDocumentChange (InL textDocumentEdit) = Just $ getParamsFromTextDocumentEdit textDocumentEdit
413416
getParamsFromDocumentChange _ = Nothing
414417

418+
bumpNewestVersion (VersionedTextDocumentIdentifier uri _) =
419+
head <$> textDocumentVersions uri
415420

416421
-- For a uri returns an infinite list of versions [n,n+1,n+2,...]
417422
-- where n is the current version

lsp-types/src/Language/LSP/Types/Lens.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{-# LANGUAGE FlexibleContexts #-}
1010
{-# LANGUAGE DataKinds #-}
1111
{-# LANGUAGE TypeInType #-}
12+
{-# LANGUAGE ExplicitNamespaces #-}
1213

1314
module Language.LSP.Types.Lens where
1415

@@ -19,6 +20,7 @@ import Language.LSP.Types.CodeAction
1920
import Language.LSP.Types.CodeLens
2021
import Language.LSP.Types.DocumentColor
2122
import Language.LSP.Types.Command
23+
import Language.LSP.Types.Common (type (|?))
2224
import Language.LSP.Types.Completion
2325
import Language.LSP.Types.Configuration
2426
import Language.LSP.Types.Declaration
@@ -391,3 +393,6 @@ makeFieldsNoPrefix ''SemanticTokensEdit
391393
makeFieldsNoPrefix ''SemanticTokensDelta
392394
makeFieldsNoPrefix ''SemanticTokensDeltaPartialResult
393395
makeFieldsNoPrefix ''SemanticTokensWorkspaceClientCapabilities
396+
397+
-- Unions
398+
makePrisms ''(|?)

0 commit comments

Comments
 (0)