-
Notifications
You must be signed in to change notification settings - Fork 94
Fix for #374 #376
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
Merged
Merged
Fix for #374 #376
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,7 +354,10 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do | |
allChangeParams <- case r ^. params . edit . documentChanges of | ||
Just (List cs) -> do | ||
mapM_ (checkIfNeedsOpened . documentChangeUri) cs | ||
return $ mapMaybe getParamsFromDocumentChange cs | ||
-- replace the user provided version numbers with the VFS ones + 1 | ||
-- (technically we should check that the user versions match the VFS ones) | ||
cs' <- traverseOf (traverse . _InL . textDocument) bumpNewestVersion cs | ||
return $ mapMaybe getParamsFromDocumentChange cs' | ||
-- Then fall back to the changes field | ||
Nothing -> case r ^. params . edit . changes of | ||
Just cs -> do | ||
|
@@ -376,12 +379,11 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do | |
-- Update VFS to new document versions | ||
let sortedVersions = map (sortBy (compare `on` (^. textDocument . version))) groupedParams | ||
latestVersions = map ((^. textDocument) . last) sortedVersions | ||
bumpedVersions = map (version . _Just +~ 1) latestVersions | ||
|
||
forM_ bumpedVersions $ \(VersionedTextDocumentIdentifier uri v) -> | ||
forM_ latestVersions $ \(VersionedTextDocumentIdentifier uri v) -> | ||
modify $ \s -> | ||
let oldVFS = vfs s | ||
update (VirtualFile oldV file_ver t) = VirtualFile (fromMaybe oldV v) (file_ver + 1) t | ||
update (VirtualFile oldV file_ver t) = VirtualFile (fromMaybe oldV v) (file_ver +1) t | ||
newVFS = updateVFS (Map.adjust update (toNormalizedUri uri)) oldVFS | ||
in s { vfs = newVFS } | ||
|
||
|
@@ -401,7 +403,7 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do | |
return $ s { vfs = newVFS } | ||
|
||
getParamsFromTextDocumentEdit :: TextDocumentEdit -> DidChangeTextDocumentParams | ||
getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) = | ||
getParamsFromTextDocumentEdit (TextDocumentEdit docId (List edits)) = do | ||
DidChangeTextDocumentParams docId (List $ map editToChangeEvent edits) | ||
|
||
editToChangeEvent :: TextEdit |? AnnotatedTextEdit -> TextDocumentContentChangeEvent | ||
|
@@ -412,6 +414,8 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do | |
getParamsFromDocumentChange (InL textDocumentEdit) = Just $ getParamsFromTextDocumentEdit textDocumentEdit | ||
getParamsFromDocumentChange _ = Nothing | ||
|
||
bumpNewestVersion (VersionedTextDocumentIdentifier uri _) = | ||
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. signature please 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'd have to write that type signature myself, without the help of the IDE!! Unacceptable |
||
head <$> textDocumentVersions uri | ||
|
||
-- For a uri returns an infinite list of versions [n,n+1,n+2,...] | ||
-- where n is the current version | ||
|
@@ -425,7 +429,7 @@ updateState (FromServerMess SWorkspaceApplyEdit r) = do | |
vers <- textDocumentVersions uri | ||
pure $ map (\(v, e) -> TextDocumentEdit v (List [InL e])) $ zip vers edits | ||
|
||
getChangeParams uri (List edits) = do | ||
getChangeParams uri (List edits) = do | ||
map <$> pure getParamsFromTextDocumentEdit <*> textDocumentEdits uri (reverse edits) | ||
|
||
mergeParams :: [DidChangeTextDocumentParams] -> DidChangeTextDocumentParams | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why? are the user-provided ones wrong?
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.
the user can target a version older than the current one