From mboxrd@z Thu Jan 1 00:00:00 1970 From: whydoubt at gmail.com (Jeffrey Smith) Date: Sat, 21 Oct 2017 16:53:15 -0500 Subject: [PATCH 4/4] ui-blame: Allow syntax highlighting In-Reply-To: <20171021144325.GF2393@john.keeping.me.uk> References: <20171018041735.31592-1-whydoubt@gmail.com> <20171018041735.31592-5-whydoubt@gmail.com> <20171021144325.GF2393@john.keeping.me.uk> Message-ID: On Sat, Oct 21, 2017 at 9:43 AM, John Keeping wrote: > > This doesn't account for tabs, which is noticable in long lines (I > happened to test with cgit.c where line 615 is quite a bit longer than > average). > > It is fixed by using: > > const char *start = blame_nth_line(sb, line); > const char *end = blame_nth_line(sb, line + 1); > > html("\n"); > len = end - start; > while (start < end) > if (*(start++) == '\t') > len += 7; > Nice catch. Since '\t' is 'advance to next tab-stop' not 'advance # spaces', that calculation could give a len larger than necessary. I will add the code to handle tabs properly. >> + if (len > maxlen) >> + maxlen = len; >> + } >> >> - html_ntxt(cp, cpend - cp); >> + for (len = 0; len < maxlen - 1; len++) >> + html(" "); > > Should this use   or is a plain space guaranteed to be okay here? This is inside of a 'pre' block, so spaces will do the right thing.