@@ -354,7 +354,10 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
354
354
allChangeParams <- case r ^. params . edit . documentChanges of
355
355
Just (List cs) -> do
356
356
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'
358
361
-- Then fall back to the changes field
359
362
Nothing -> case r ^. params . edit . changes of
360
363
Just cs -> do
@@ -401,7 +404,7 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
401
404
return $ s { vfs = newVFS }
402
405
403
406
getParamsFromTextDocumentEdit :: TextDocumentEdit -> DidChangeTextDocumentParams
404
- getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) =
407
+ getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) = do
405
408
DidChangeTextDocumentParams docId (List $ map editToChangeEvent edits)
406
409
407
410
editToChangeEvent :: TextEdit |? AnnotatedTextEdit -> TextDocumentContentChangeEvent
@@ -412,6 +415,8 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do
412
415
getParamsFromDocumentChange (InL textDocumentEdit) = Just $ getParamsFromTextDocumentEdit textDocumentEdit
413
416
getParamsFromDocumentChange _ = Nothing
414
417
418
+ bumpNewestVersion (VersionedTextDocumentIdentifier uri _) =
419
+ head <$> textDocumentVersions uri
415
420
416
421
-- For a uri returns an infinite list of versions [n,n+1,n+2,...]
417
422
-- where n is the current version
0 commit comments