Closed vesdev closed 1 month ago
also updated minor version of ahash as 0.8.3 does not compile for me, did not bother separating it into a different commit as its a very small change
Looking more into it there is something funky with the wrapping. start_index is not correct after the line is built for the first_line_msg
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 17.87%. Comparing base (
31bcc1c
) to head (46248bc
). Report is 1 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
I think I know what the issue is. When finding the indices to highlight, the message contains a newline character, which is then removed when splitting the message into multiple lines. This leads to the start_index not matching the highlight index.
A solution might be to just strip newlines from the message when trying to find the sections to highlight, or maybe just do a +1 to the start index only when the current line contained a newline.
Your solution, if I'm right, would give us an off by one highlight when the message spans more than one line without containing a newline.
Let me know if you need any more help with the PR.
I think I know what the issue is. When finding the indices to highlight, the message contains a newline character, which is then removed when splitting the message into multiple lines. This leads to the start_index not matching the highlight index.
A solution might be to just strip newlines from the message when trying to find the sections to highlight, or maybe just do a +1 to the start index only when the current line contained a newline.
Your solution, if I'm right, would give us an off by one highlight when the message spans more than one line without containing a newline.
Let me know if you need any more help with the PR.
Looking at textwrap docs, wrap() should not include a trailing newline char. https://docs.rs/textwrap/latest/textwrap/fn.wrap.html
Sorry I haven't replied yet, busy with IRL stuff. I'll take a look at this when I can.
Tested between branches, this fix looks to work perfectly. Thanks for the PR!
I'm afraid this PR breaks the case where the line just overflows onto the next line, without a line break.
This is from current git main branch:
The full solution needs to check where the newlines are in the message, then increment the start_index at the right time.
I can make a PR that fixes this, unless @vesdev wants to do it?
Edit: Fixed bad image
Ah hell I thought I tested that, my bad. Good thing I didn't do a release for it :sweat_smile:
I'm afraid this PR breaks the case where the line just overflows onto the next line, without a line break.
This is from current git main branch:
The full solution needs to check where the newlines are in the message, then increment the start_index at the right time.
I can make a PR that fixes this, unless @vesdev wants to do it?
Edit: Fixed bad image
Yea feel free to, the proper fix I think would be using the textwrap output for getting the highlight indices instead of the message payload. Didn't think about break_word 🤔
before![image](https://github.com/user-attachments/assets/7f6b13dc-d73e-465a-964c-896702b930ae)
after![image](https://github.com/user-attachments/assets/95f9a894-6311-4469-b2f3-79431d25275a)
it does not account for the newlines properly
shoutout to mostlymaxi's chat for noticing this