pronto-clang_format 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fe7b8b5605c1b8f0412b956371ecad612216fcdaf2cddb8ea68c9436f346db3
|
4
|
+
data.tar.gz: 6b2e07eef94cf67d213d1cdeccd103d9eb4aabb9cd458138af1cee08a5cce3f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a16d084a2da8626789f91b5691cc6236c2742afc51a67923a7989f341eb9344728a89cb08c7d010ad24627709d6209d7018d71f1b4fced8ac514f208b808ca12
|
7
|
+
data.tar.gz: ce6ef55cc378d4ffac01d9c2716c005729b38d03b7d1ddbb4ed13fa43bb0e962760302cc19ec503d8abf54aeea6b7d54f991a37b16295bf179e6cfecf42c33de
|
@@ -57,9 +57,8 @@ module Pronto
|
|
57
57
|
end_line_no, = ln_col_from_offset(newlines_array, offset + length)
|
58
58
|
# extract relevant lines and pass to offence
|
59
59
|
start_offset = offset_from_ln_col(newlines_array, line_no, 1)
|
60
|
-
end_offset = offset_from_ln_col(newlines_array, end_line_no + 1,
|
61
|
-
old_lines_text = file_contents[start_offset..end_offset]
|
62
|
-
.prepend("\n")
|
60
|
+
end_offset = offset_from_ln_col(newlines_array, end_line_no + 1, -1)
|
61
|
+
old_lines_text = "\n#{file_contents[start_offset..end_offset]}\n"
|
63
62
|
Offence.new(offset, line_no, column, length, replacement,
|
64
63
|
old_lines_text)
|
65
64
|
end
|
@@ -87,6 +86,8 @@ module Pronto
|
|
87
86
|
# newline_offsets_in(file_contents)
|
88
87
|
# - offset: offset to be converted
|
89
88
|
def offset_from_ln_col(newlines_array, ln, col)
|
89
|
+
# return -1 if the line does not exist in file
|
90
|
+
return -1 unless ln - 2 < newlines_array.length
|
90
91
|
(ln >= 2 ? newlines_array[ln - 2] : -1) + col
|
91
92
|
end
|
92
93
|
|