Skip to content

Commit 01edd4c

Browse files
committed
Fix comment column end bug
Only use the start and end columns on the first and last line of the comment. Previously, a shorter line at the end would result in the previous lines leaving information behind.
1 parent 27918dd commit 01edd4c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

pygccxml/parser/scanner.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,16 @@ def _handle_comment(self, declaration):
218218
file_text = self.__files_text.get(file_decl)
219219
# Use lines and columns to capture only comment text
220220
for indx in range(comm_decl.begin_line - 1, comm_decl.end_line):
221+
# Col data only useful on first and last lines
222+
strt_idx = 0
223+
end_idx = -1
224+
if indx == comm_decl.begin_line - 1:
225+
strt_idx = comm_decl.begin_column - 1
226+
if indx == comm_decl.end_line - 1:
227+
end_idx = comm_decl.end_column
221228
comm_line = file_text[indx]
222229
comm_line = comm_line[
223-
comm_decl.begin_column - 1:comm_decl.end_column
230+
strt_idx:end_idx
224231
]
225232
# Remove newlines from end of string
226233
comm_line = comm_line.rstrip("\n")

0 commit comments

Comments
 (0)