Skip to content
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

fix unicode issues and implement left truncation #285

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

moh-eulith
Copy link

See #283

@estk
Copy link
Owner

estk commented Oct 17, 2022

thanks

@moh-eulith moh-eulith marked this pull request as draft October 17, 2022 17:24
@moh-eulith
Copy link
Author

Pushed new code that addresses both the existing unicode issues and adds left truncation.

@moh-eulith moh-eulith marked this pull request as ready for review October 25, 2022 01:03
@moh-eulith moh-eulith changed the title unicode combining test case fix unicode issues and implement left truncation Oct 28, 2022
@estk
Copy link
Owner

estk commented Oct 30, 2022

Hi @moh-eulith there is a lot of diff churn here, can you ensure that no rearranging happens? If you'd like to do some refactoring lets split that into a separate PR

@moh-eulith
Copy link
Author

Diff was just trying too hard to make sense of a simple delete/add. Moved the add and now diff is a lot more readable.

@moh-eulith
Copy link
Author

Is the diff ok now?

@estk
Copy link
Owner

estk commented Nov 17, 2022

Diff is looking good!
I'll pull the changes and have a close look now.

@estk estk self-assigned this Nov 17, 2022
Style(Style),
}

struct StringBasedWriter<'a> {
Copy link
Owner

@estk estk Nov 17, 2022

Choose a reason for hiding this comment

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

nit: prefer usefully named lifetime params such as 'writer or 'params.
nit: although a single lifetime works here if someone uses those params separately they will need to refactor this struct to use separate lifetimes.

}

enum StringOrStyle {
String(GraphemeLenString),
Copy link
Owner

Choose a reason for hiding this comment

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

nit: suggest using struct-style variant

params: &'a Parameters,
}

impl<'a> encode::Write for StringBasedWriter<'a> {
Copy link
Owner

@estk estk Nov 17, 2022

Choose a reason for hiding this comment

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

nit:
the lifetime(s) dont need to be named here

impl encode::Write for StringBasedWriter<'_, '_> {

if let Ok(Some(x)) = r {
start = x;
} else {
// this should never happen, as we sanitize with to_utf8_lossy
Copy link
Owner

Choose a reason for hiding this comment

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

Are we sure about this? Seems like it could, given any input of g and count if we rely on assumption that should be at least documented if not checked.

Copy link
Author

Choose a reason for hiding this comment

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

We don't rely on that assumption. Clarified the comment.

@estk
Copy link
Owner

estk commented Nov 17, 2022

Looks good other than above comments.

@moh-eulith
Copy link
Author

addressed review comments and added a bit of documentation

@moh-eulith
Copy link
Author

Is there anything else I can address for this PR?

@bconn98
Copy link
Collaborator

bconn98 commented Dec 23, 2023

@moh-eulith Lets get this rebased with the latest as a start and we can take another look

@moh-eulith
Copy link
Author

@bconn98 done.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 86.13861% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 64.12%. Comparing base (f688e38) to head (825609f).

Files Patch % Lines
src/encode/pattern/mod.rs 85.85% 14 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
+ Coverage   63.42%   64.12%   +0.70%     
==========================================
  Files          25       25              
  Lines        1572     1586      +14     
==========================================
+ Hits          997     1017      +20     
+ Misses        575      569       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@estk
Copy link
Owner

estk commented Jul 9, 2024

Is this ready for another look?

@moh-eulith
Copy link
Author

moh-eulith commented Jul 9, 2024

Is this ready for another look?

Yes.

@moh-eulith moh-eulith requested a review from estk July 19, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support truncating from the left, width padding/truncation incorrect with some unicode input
4 participants