Closed sgn closed 2 years ago
Thank you for providing us with a fix! 👍
Before I merge, I'd like to understand the change a little better, if that's OK with you. In the call to u32_move()
, you changed the number of characters moved. It is calculated as input.lines[j].num_chars - input.lines[j].posmap[c] + 1
, where num_chars
is in characters, but posmap[c]
is in bytes. How does that result in a valid number? Or is my assumption about num_chars
incorrect?
Your assumption about num_chars
is correct. It's counted by characters. However, posmap[c]
is in characters, too.
Quoting your code:
https://github.com/ascii-boxes/boxes/blob/7de6854fd97e9fc256f1cf847cbc37c9f0f1cf1c/src/boxes.in.h#L146
Ah, right, I get it now. I literally wrote this in the previous millennium, so bear with me. 😊
posmap
gives the position in mbtext
for each visible character. All the invisible characters, like ANSI color codes, are ignored. The full posmap
looks like this:
In this test case, we want to remove 3 spaces from the beginning of the string, which means that we must remove 55 characters, including lots of invisible ones. So, as you said from the start, we were moving too many characters.
See #103 and https://github.com/void-linux/void-packages/issues/39624