We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0d81416 commit 9de83f6Copy full SHA for 9de83f6
lib/rdoc/generator.rb
@@ -1043,12 +1043,18 @@ def add_line_numbers(src)
1043
first = $1.to_i - 1
1044
last = first + src.count("\n")
1045
size = last.to_s.length
1046
- real_fmt = "%#{size}d: "
1047
- fmt = " " * (size+2)
+ fmt = "%#{size}d: "
+ is_first_line = true
1048
+ line_num = first
1049
src.gsub!(/^/) do
- res = sprintf(fmt, first)
1050
- first += 1
1051
- fmt = real_fmt
+ if is_first_line then
+ is_first_line = false
1052
+ res = " " * (size+2)
1053
+ else
1054
+ res = sprintf(fmt, line_num)
1055
+ end
1056
+
1057
+ line_num += 1
1058
res
1059
end
1060
0 commit comments