Skip to content

Commit

Permalink
improve tabs handling
Browse files Browse the repository at this point in the history
for the time being this seems good enough.  In the future we may want
to expand a tab into N spaces tho.
  • Loading branch information
omar-polo committed Jun 12, 2021
1 parent b66b4b8 commit 421bca4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ utf8_cplen(char *s)
return len;
}

/* returns only 0, 1 or 2. assumes sizeof(wchar_t) is 4 */
/* returns only 0, 1, 2 or 8. assumes sizeof(wchar_t) is 4 */
size_t
utf8_chwidth(uint32_t cp)
{
Expand All @@ -131,6 +131,14 @@ utf8_chwidth(uint32_t cp)
* it must use UTF-16... right? */
assert(sizeof(wchar_t) == 4);

/*
* quick and dirty fix for the tabs. In the future we may
* want to expand tabs into N spaces, but for the time being
* this seems to be good enough (tm).
*/
if (cp == '\t')
return 8;

return wcwidth((wchar_t)cp);
}

Expand Down

0 comments on commit 421bca4

Please sign in to comment.