Make line numbers right-aligned in source listings #93

Open
wapcaplet opened this Issue Mar 9, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@wapcaplet
Contributor

wapcaplet commented Mar 9, 2012

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

This comment has been minimized.

Show comment
Hide comment
@abedra

abedra Mar 9, 2012

Contributor

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

Contributor

abedra commented Mar 9, 2012

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

wapcaplet added a commit to wapcaplet/rcov that referenced this issue Mar 9, 2012

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.

abedra added a commit that referenced this issue Mar 9, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment