Skip to content

executeCommand/applyEdit sends a DocumentDidChange notification before bumping the file version #374

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

Closed
pepeiborra opened this issue Dec 14, 2021 · 1 comment
Labels
component: lsp-test Specific issues of lsp-test package help wanted type: bug

Comments

@pepeiborra
Copy link
Collaborator

pepeiborra commented Dec 14, 2021

As reported in haskell/haskell-language-server#2479, this makes it very difficult to write tests that want to reason on a sequence of commands:

-- TODO: Don't do this when replaying a session
forM_ mergedParams (sendMessage . NotificationMessage "2.0" STextDocumentDidChange)
-- 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) ->
modify $ \s ->
let oldVFS = vfs s
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 }

@jneira jneira added component: lsp-test Specific issues of lsp-test package type: bug help wanted labels Dec 14, 2021
pepeiborra added a commit that referenced this issue Dec 15, 2021
pepeiborra added a commit that referenced this issue Dec 16, 2021
pepeiborra added a commit that referenced this issue Dec 16, 2021
michaelpj pushed a commit that referenced this issue Dec 20, 2021
* Improve error message

* Add test for #374

* Add fix

* avoid double version bump

* add a comment
@michaelpj
Copy link
Collaborator

Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lsp-test Specific issues of lsp-test package help wanted type: bug
Projects
None yet
Development

No branches or pull requests

3 participants