Skip to content

The current positionmappings is composing in the wrong way in lastValueIO #3919

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
soulomoon opened this issue Dec 23, 2023 · 1 comment · Fixed by #3920
Closed

The current positionmappings is composing in the wrong way in lastValueIO #3919

soulomoon opened this issue Dec 23, 2023 · 1 comment · Fixed by #3920
Labels
status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@soulomoon
Copy link
Collaborator

soulomoon commented Dec 23, 2023

I discover the problem when developing Semantic tokens

          I observed a bizzared behaviour when using possition mappings
          in vscode.
          in the first 6 space insert, the using possition mapping to ident the code seems to be working,
          Then the column at the start position stop to update
          ```
          Range {_start = Position {_line = 139, _character = 16}, _end = Position {_line = 139, _character = 25}} spanNames_atz7
          Range {_start = Position {_line = 139, _character = 17}, _end = Position {_line = 139, _character = 26}} spanNames_atz7
          Range {_start = Position {_line = 139, _character = 17}, _end = Position {_line = 139, _character = 27}} spanNames_atz7
          ```
          
          <img width="259" alt="Screenshot 2023-12-23 at 13 19 25" src="https://github.com/haskell/haskell-language-server/assets/14073857/3e98cb7f-9f45-4c60-a37a-e499b3cca129">
          
          here is another one
          ```
          Range {_start = Position {_line = 25, _character = 13}, _end = Position {_line = 25, _character = 19}} xxxxx_aTsW
          Range {_start = Position {_line = 25, _character = 13}, _end = Position {_line = 25, _character = 20}} xxxxx_aTsW
          # with
          [TextDocumentContentChangeEvent (InL (#range .== Range {_start = Position {_line = 25, _character = 9}, _end = Position {_line = 25, _character = 9}} .+ #rangeLength .== Just 0 .+ #text .== " "))]
          ```

Originally posted by @soulomoon in #3892 (comment)
When useWithStale, the old delta is mistakenly be considered as new.
I will open a pull request to fix this.

@soulomoon soulomoon added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Dec 23, 2023
@soulomoon
Copy link
Collaborator Author

soulomoon commented Dec 23, 2023

Actually the error happens on the 6th insertions. Just not visible.

The behaviour is subtle on just inserting spaces consistantly:
say the each insertion of whitespace at left of the following.
(x, y), (x+1, y), , (x+2, y) ...
the code let spanNames start at (x,y), notice spanNames start at (x+5). (Suppose this is what the stale version is)
the code after 5 insertions is let spanNames start at (x+5,y). Notice spanNames moves from the stale version
from x+5 to x+10 at the 5th insertions which is at the left of x+5.
Also notice the 6th insertion would happens at left of x+6.
Here x+6 > x+5, notice the x+5 which is the start of spanNames at the stale version.
stop moving to x+6. It indicate the toCurrent mapping stack is being upside down.

@soulomoon soulomoon changed the title The current delta is composing in the wrong way in lastValueIO The current positionmappings is composing in the wrong way in lastValueIO Dec 25, 2023
@mergify mergify bot closed this as completed in #3920 Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant