Skip to content

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

Merged
merged 11 commits into from
Jan 3, 2024

Conversation

soulomoon
Copy link
Collaborator

@soulomoon soulomoon commented Jan 1, 2024

It should simplify a bit of the conversion logic. Although the asymptotic complexity doe not change.
This is the second attempt of #436

Copy link
Collaborator Author

@soulomoon soulomoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soulomoon
Copy link
Collaborator Author

I finish the migration, @michaelpj @Bodigrim .
See if this look good?

Copy link
Collaborator

@michaelpj michaelpj left a 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)
Copy link
Collaborator

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!

Copy link
Collaborator Author

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 :(

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.
Copy link
Collaborator

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...

Copy link
Collaborator Author

@soulomoon soulomoon Jan 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants