-
Notifications
You must be signed in to change notification settings - Fork 93
Migrate VFS to Data.Text.Utf16.Rope.Mixed #423
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
Comments
I'll give it a go. I haven't yet had the time to really start using this stuff in HLS, so I don't really have any idea whether the current implementation is a significant performance problem. My suspicion is that it will turn out to be fine, since we're only paying costs linear in line length, but really we would have to try it. So perhaps it's not worth expending too much effort on optimizing this for now? I won't say no to a better implementation, though :) |
It should simplify code a lot, e. g., codePointPositionToPosition :: VirtualFile -> CodePointPosition -> J.Position
codePointPositionToPosition vFile (CodePointPosition cpl cpc) =
J.Position (fromIntegral cul) (fromIntegral cuc)
where
text = _file_text vFile
(prefix, _) = Rope.charSplitAtPosition (Char.Position (fromIntegral cpl) (fromIntegral cpc)) text
Utf16.Position cul cuc = Rope.utf16LengthAsPosition prefix |
Done now, thanks @Bodigrim and @soulomoon ! |
I've added a new flavour of
Rope
, which offers simultaneous indexing by Unicode code points and by UTF-16 code units without conversions. @michaelpj could you please give it a try? If it works satisfactory, I'll release it astext-rope-0.2
.https://github.com/Bodigrim/text-rope/tree/1f721c1936cbfb1ea4a742f12754047afdcff3a8
The text was updated successfully, but these errors were encountered: