Adjusting column width with _ doesn't seem to work as intended with wide/full width characters as used in East Asian languages.
Consider this sample csv data:
澹卞紣鍙傚洓浜斿叚涓冨叓涔濇嬀,ok,test-test
this is a test,test two, test three
On the second row everything looks fine, but on the first row _ is weird for all columns, not just the first one.
You should be able to compute the display width of a string with something like this:
import unicodedata
def get_display_width(text):
width = 0
for cc in text:
if unicodedata.east_asian_width(cc) in 'FWA':
width += 2
else:
width += 1
return width
Hi @polm!
Can you clarify what you meant by it is weird for all columns?
I have been able to reproduce using benchmarks.csv that _ underestimates what the max width is for cells with special characters.
If: that is what you meant, yeah that is definitely an issue, nice catch. =) Thanks for letting us know. We will fix it up soon.
Else: Would you mind sharing a screenshot? :blush:
If: that is what you meant, yeah that is definitely an issue, nice catch. =) Thanks for letting us know. We will fix it up soon.
That's the issue, yes. I though resizing was also weird for columns to the right of the one with wide characters (thus "all columns") but I can't reproduce it so I must have been confused.
Could I submit a PR to fix this? I see you have code like what I suggested above already but are just not using it in the column resizing part.
@polm Yes!
Please do. :blush: We use the develop branch for development. Please submit the PR against that branch. =)
@polm fixed the issue in https://github.com/saulpw/visidata/pull/284. Closing.