-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: multibyte line trucation #162
Conversation
I took the lazy path of using the already existing function - |
Note: While I was at it, I fixed an incorrect |
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.
Neat! Good fix.
split_long_word
does exactly what you want here. However, in contrast to the previous usecase, you're not only splitting words but a string that might contain delimiters.
So if that's ok for you, it would be awesome if you could add a new commit in which you rename split_long_word
to split_string
and adjust the docstring accordingly. Otherwise I'll do that myself once this is merged :).
let surplus = (last_line.width() + 3) - width; | ||
last_line.truncate(last_line.width() - surplus); | ||
let split_result = split_long_word(last_line.width() - surplus, &last_line); |
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.
Please do a double check :D
last_line.width() - surplus
is effectively last_line.width() - (last_line.width() + 3 - width)
, which can be simplified to width - 3
right?
Not sure why I did it that complicated before.
It's kinda funny that the exact same lines of code have been touched in #163, which has been opened at around the same time as your MR. Crazy coincidence. Anyway, since that one got merged more quickly, please do a quick rebase on |
Superseded by #171 Thanks for the contribution anyhow, much appreciated :) |
oopss... sorry for not following up, happy that someone else took the initiative |
Don't worry :D I know how it is |
In some cases of cell content truncation (i.e. when the last line displayed has to be truncated to add ellipses), the library would throw an error if the content contained multi-byte characters
See the added test case and note that it previously failed