-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor getLine to return TextLines/Rope #7
Conversation
It feels a bit strange when |
That would be fine I guess. Bascially we need the mixed-encoding indexing that we get from |
getLine lineIdx rp = | ||
case T.unsnoc firstLine of | ||
fromText $ case T.unsnoc firstLine of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to return Rope
, can we avoid firstLineRope
and stick to firstLineRope
? Otherwise we are doing a double conversion.
I guess the neatest alternative would be to provide some utilities for mixed-encoding indexing of |
After thinking about it, I'm largely fine with both options:
|
I'll get to it over weekend. Will probably go with option 2 (keep Rope/TextLines). |
@jhrcek @michaelpj I'm uncomfortable that |
Coming back to this, I don't feel so bad about just getting |
Ok, unless there are strong objections, I would close this PR and keep the current Text-returning implementation. |
I gave it a stab in 3a46aaf. Thanks for trailblazing! |
As @michaelpj pointed out, for many use-cases it might be preferable if getLine stays within the world of Ropes, to allow for further processing (an example of this is in lsp and similar, currently incorrect usage of getLine-like functionality mentioned in this comment in hls: haskell/haskell-language-server#4303 (comment)
The initial impl. ini this PR might not be ideal, because its complexity is linear in the length of line being wrapped. But let me open a PR to get initial feedback.