tbabej / vit

Placeholder to demostrate issue porting for VIT.
0 stars 0 forks source link

[VT-121] incorrect column width with CJK (doublewidth) characters? #120

Closed tbabej closed 6 years ago

tbabej commented 6 years ago

Alick Zhao on 2015-06-03T11:12:30Z says:

It seems that the columns are not aligned right when the task description contains CJK characters, each of which typically is twice as wide as Latin characters in terminal. See the attached screenshot.

BTW, task warrior can show columns right in terminal. Screenshot attached.

tbabej commented 6 years ago

Migrated metadata:

Created: 2015-06-03T11:12:30Z
Modified: 2016-09-02T19:41:04Z
tbabej commented 6 years ago

Scott Kostyshak on 2015-06-03T15:45:22Z says:

Thank you for this well-written bug report, Alick. I agree with your argument that this is Vit's bug (and not, e.g. Taskwarrior's). I believe this is related to the following bug: https://bug.tasktools.org/browse/VT-100

I have very little experience with this type of issue. When I have some time I would like to test linking Vit against libncursesw5 and then using the functions wgetch() and wget_wch(). If anyone beats me to testing that, or providing a patch, I would of course be very appreciative.

tbabej commented 6 years ago

Alick Zhao on 2015-06-04T02:30:59Z says:

IIRC taskwarrior had similar issues but was later fixed. This bug might be related: https://bug.tasktools.org/browse/TW-533 Seems like they just update the wcwidth.c routines.

In C, wcwidth() and friends can be used to get the "correct" character width [1]. Git also has its own implementation [2]. But honestly I am not sure how it is done in Perl.

[1] https://stackoverflow.com/questions/3634627/how-to-know-the-preferred-display-width-in-columns-of-unicode-characters [2] https://github.com/git/git/blob/master/utf8.c

tbabej commented 6 years ago

Scott Kostyshak on 2015-06-04T12:52:01Z says:

Great, thanks for the notes, Alick. Those will come in useful.

tbabej commented 6 years ago

Scott Kostyshak on 2016-08-14T05:39:09Z says:

Alick can you please test the 1.3 branch in the git repo? Thanks to a contributor, some fixes related to multi-byte characters were just pushed and I think there's a good chance they cover this issue. Specifically, 77a9f97b. Note that I consider the 1.3 branch pretty stable and hope to move to 1.3beta1 soon.

tbabej commented 6 years ago

Alick Zhao on 2016-08-27T02:48:16Z says:

Thanks! Will update my copr build for vit 1.3 branch [1] and have a test soon.

[1] https://copr.fedorainfracloud.org/coprs/alick/vit/

tbabej commented 6 years ago

Alick Zhao on 2016-08-27T04:10:40Z says:

task warrior command line output

tbabej commented 6 years ago

Alick Zhao on 2016-08-27T04:11:20Z says:

vit 1.3 dev output

tbabej commented 6 years ago

Alick Zhao on 2016-08-27T04:13:24Z says:

Hi,

As attached in the two new screenshots, vit seems to calculate the width incorrectly still, but this time it's underflow instead of overflow.

tbabej commented 6 years ago

Scott Kostyshak on 2016-08-27T12:40:57Z says:

Thanks for testing, Alick. I think I can reproduce by just pasting the chacters 假借字 into a prompt. I'll see if the person who contributed the other patches can take a look at this.

tbabej commented 6 years ago

Scott Kostyshak on 2016-08-31T14:30:01Z says:

Should be fixed in latest 1.3 branch (which will become 1.3 beta), as of commit a7368863. A big thanks to Richard Gay, who did all of the work.

Alick can you please confirm? I have tested by pasting 假借字 into a prompt, adding those characters in a task and looking if the columns look fine, and everything seems to work well. But having confirmation from you would be great. Sorry for the bother.

tbabej commented 6 years ago

Alick Zhao on 2016-08-31T17:18:23Z says:

Thanks! Will try to build and test tonight.

tbabej commented 6 years ago

Alick Zhao on 2016-09-02T04:05:02Z says:

Sorry for being late. I've tested it and it looks very good now! Thanks!!

tbabej commented 6 years ago

Scott Kostyshak on 2016-09-02T19:41:04Z says:

Fixed at a7368863, thanks to Richard Gay.