relevance/rcov — Issue #93: Make line numbers right-aligned in source listings
Author: wapcaplet
Created: 2012-03-09 18:24:05+00:00
State: open

This issue is only a minor annoyance, but it would be nice if the line numbers in HTML source listings (generated by `lib/rcov/templates/detail.html.erb`) were right-aligned, so the code indentation would appear more consistent. For example, here's how it looks now:

```
7 def foo(x)
8 if x > 5
9 puts 'x > 5'
10 else
11 puts 'x <= 5'
12 end
13 end
```

Note the subtle shift in indentation between lines 9 and 10, caused by the single-digit line numbers not having any padding. The padding could be on either side, but I'd prefer it on the left (since that's how Vim does it):

```
7 def foo(x)
8 if x > 5
9 puts 'x > 5'
10 else
11 puts 'x <= 5'
12 end
13 end
```

This looks like a pretty easy fix--count the digits in the maximum line number, then use `rjust` to add some spaces; I will work on a patch and submit a pull request.