From 4bccfab6324c8c8bc8106e65c4aec076f5d121be Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 11 Jul 2012 01:22:32 -0700 Subject: [PATCH] Make 'show_line()' do proper TAB handling The TAB handling got broken by commit cee00b0efb86 ("Show UTF-8 input as UTF-8 output") when it stopped doing things one byte at a time. I'm sure the other special character cases are broken too. Signed-off-by: Linus Torvalds --- display.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/display.c b/display.c index 676514d..326dc9e 100644 --- a/display.c +++ b/display.c @@ -442,13 +442,26 @@ static void show_line(struct line *lp) while (i < len) { unicode_t c; + int n; - i += utf8_to_unicode(lp->l_text, i, len, &c); - if (vtcol >= term.t_ncol) + if (vtcol >= term.t_ncol) { vp->v_text[term.t_ncol - 1] = '$'; - else if (vtcol >= 0) - vp->v_text[vtcol] = c; + return; + } + n = utf8_to_unicode(lp->l_text, i, len, &c); + /* + * Change tabs into spaces, and don't increment + * the text source until we hit tabmask + */ ++vtcol; + if (c == '\t') { + c = ' '; + if (vtcol & tabmask) + n = 0; + } + if (vtcol > 0) + vp->v_text[vtcol-1] = c; + i += n; } }