Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make line numbers right-aligned in source listings #93

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

Make line numbers right-aligned in source listings #93

wapcaplet opened this issue Mar 9, 2012 · 1 comment

Comments

@wapcaplet
Copy link
Contributor

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
Copy link
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
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants