Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Scry formatting bug #35

Closed
faustinoaq opened this issue Oct 22, 2017 · 1 comment
Closed

Scry formatting bug #35

faustinoaq opened this issue Oct 22, 2017 · 1 comment
Labels

Comments

@faustinoaq
Copy link
Member

On ST3 to reproduce this issue try scry formatting disabling crystal auto_format on crystal package setting:

{
  "auto_format": false,
  "crystal_cmd": "crystal"
}

bug01

As you can see scry formatting is almost deleting all file text.

Ref: #34

@bmulvihill
Copy link
Contributor

@faustinoaq Did some digging on this - I believe it is due to the way Sublime LSP sets its text points. So we send the our response which contains different ranges. These ranges get converted into Sublime Regions. Sublime is overlapping the regions it creates because all of our text edits have the same MAX value, which essentially converts them all into one region (This is why we are only seeing the first line get formatted )https://github.com/crystal-lang-tools/scry/blob/master/src/scry/formatter.cr#L34

I looked at how Go's Language server does it and it looks like they send back a single text edit for the entire format https://github.com/sourcegraph/go-langserver/blob/master/langserver/format.go#L53. I did the same on our and it seems to solve the problem, since we only send back a single Range and Sublime uses a single region. Is there any particular reason we would need to send back each individual TextEdit since we end up formatting the entire document anyway?

faustinoaq pushed a commit that referenced this issue Oct 24, 2017
- Fixes #35 
- Formats document with a single TextEdit rather than many since we end up formatting the entire source anyway
@faustinoaq faustinoaq added this to Done in Crystal Tools Apr 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Crystal Tools
  
Done
Development

No branches or pull requests

2 participants