-
Notifications
You must be signed in to change notification settings - Fork 93
Update Data.Text.Utf16.Rope to Data.Text.Utf16.Rope.Mixed #542
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
Conversation
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.
—
I finish the migration, @michaelpj @Bodigrim . |
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.
Great, thank you!
cuc <- codePointOffsetToCodeUnitOffset utfLine (fromIntegral cpc) | ||
pure $ J.Position l (fromIntegral cuc) | ||
lineRope <- extractLine text $ fromIntegral l | ||
guard $ c <= fromIntegral (Rope.charLength lineRope) |
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.
I think we should include a comment about why we're not using Rope.splitAtPosition
. The difference is quite subtle!
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.
splitAtPosition just wrapped over the line. when column index out of range or when the column indexing at the newline char :(
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.
The first out of range problem is easy to deal with,
But the second case when the column indexing at the newline char and still wrapped over the line, it becomes the pain.
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.
comment added
@@ -458,15 +427,12 @@ codeUnitOffsetToCodePointOffset rope offset = do | |||
the position. |
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.
Hmm, is this definitely still the same? For some reason I thought it might be faster 🤔 But maybe it's just that the code is simpler...
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.
It just remove the fromText and toText part, saving the conversion, other logic still the same.
since the mixed version have two indices, one for codePoint, one for utf16.
Should be a little faster, since saving the reindexing.
It should simplify a bit of the conversion logic. Although the asymptotic complexity doe not change.
This is the second attempt of #436