[PATCH 4/4] ui-blame: Allow syntax highlighting
Jeffrey Smith
whydoubt at gmail.com
Sat Oct 21 23:53:15 CEST 2017
On Sat, Oct 21, 2017 at 9:43 AM, John Keeping <john at keeping.me.uk> 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.
More information about the CGit
mailing list