haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

Test Rope.getLine

Open jhrcek opened this issue 1 year ago • 5 comments

Just testing out newly introduced utility from text-rope

jhrcek avatar Jun 09 '24 12:06 jhrcek

We also do this a bunch in lsp, I think.

michaelpj avatar Jun 09 '24 13:06 michaelpj

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?

jhrcek avatar Jun 09 '24 15:06 jhrcek

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.

michaelpj avatar Jun 09 '24 15:06 michaelpj

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 avatar Jun 09 '24 15:06 michaelpj

@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

jhrcek avatar Jun 11 '24 14:06 jhrcek