Open jhrcek opened 2 weeks ago
We also do this a bunch in lsp
, I think.
We also do this a bunch in lsp, I think.
@michaelpj Hmm, in lsp there's some extractLine in LSP which returns a Rope and does further manipulation on that Rope, which means that the new function I introduced is probably useless. Or do you think that the function I introduced should return a Rope?
Hmm, that's a little annoying. We return a Rope
so we can use the mixed encoding indexing which text-rope
provides, but conceptually it's just a one-line Text
. I don't know if there are comparable mixed-indexing functions for plain Text
? If so we can switch to use your getLine
.
Note that it's quite likely that functions in HLS also need this facility. Remember that much of HLS incorrectly assumes that it can use LSP positions as GHC positions or as indexes into Text
. So e.g. this line is wrong: it needs to drop c
UTF-16 code units, whereas Text.drop
drops code units.
So HLS might also prefer to get a Rope
. Or it should use rangeLinesFromVFS
from lsp
, which does this correctly.
@michaelpj I opened a followup PR in text-rope that makes getLine "stay in the Rope world". Would it make more sense to you like that? https://github.com/Bodigrim/text-rope/pull/7
Just testing out newly introduced utility from text-rope