Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make line numbers right-aligned in source listings #93

Open
wapcaplet opened this Issue · 1 comment

2 participants

@wapcaplet

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.

@abedra
Owner

I have no interest in doing the work for this, but I will be happy to review a patch if one is provided.

@wapcaplet wapcaplet referenced this issue from a commit in wapcaplet/rcov
@wapcaplet wapcaplet Issue #93: Right-justify line numbers
This commit causes the line numbers in HTML source listings to be
right-justified, allowing the code indentation to appear more
consistent.
3d1eca6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.