Open ckipp01 opened 4 years ago
Thanks for bringing that up! We don't track the version numbers.
What would be the expected behavior here in case of renames? Would we just increase the number by one and return that? Or should it be just the same number as we received?
Anyway, it should be easy to implement, though I don't think we've seen a purpose to do it yet.
So looking at the internals of the Nvim LSP implementation it looks like if we triggered a rename and document locally had been changed in-between, then the buffer version locally would be higher than the version we are sending back. It'd then reject that edit.
So I think that's a sensible use-case.
So looking at the internals of the Nvim LSP implementation it looks like if we triggered a rename and document locally had been changed in-between, then the buffer version locally would be higher than the version we are sending back. It'd then reject that edit.
So I think that's a sensible use-case.
We most likely haven't been hit by this since the renames are usually quick.
We most likely haven't been hit by this since the renames are usually quick.
Metals is that fast. š
Describe the bug According to the spec when a
VersionedTextDocumentIdentifier
is used like we do in in theRenameProvider.scala
, the version can either benull
to indicate the version is known or a number to indicate another change. From the spec:In the rename provider we always just return
null
no matter what. Even if we undo the change, redo it again, or just submit a whole other rename. This doesn't seem to be a problem for us for a couple reasons.VersionedTextDocumentIdentifier
s all over the place.Here is the relevant code:
https://github.com/scalameta/metals/blob/411c792e144a28d3c35f7a3ef4846b775e139de0/metals/src/main/scala/scala/meta/internal/rename/RenameProvider.scala#L177-L187
I ran into this because currently there is a bug in the built-in lsp support in Nvim, where they weren't accounting for this being null, and renames fail with Metals. Again, that's not necessarily Metal's fault, but it does point to use never actually setting the version.
To Reproduce Steps to reproduce the behavior:
Expected behavior That after some changes, undos, renames etc, that the
VersionedTextDocumentIdentifier
would indeed be versioned.Search terms LSP, VersionedTextDocumentIdentifier, rename, nvim