diff --git a/TodoParser.py b/TodoParser.py index 42173d0..6995aed 100644 --- a/TodoParser.py +++ b/TodoParser.py @@ -547,7 +547,7 @@ class TodoParser(object): comment = comment.strip() pre_marker_length = original_comment.find(comment) else: - comment_segments = re.search(fr'^(.*?)({marker["pattern"]})(\s*)(.*)', comment) + comment_segments = re.search(fr'^(.*?)({marker["pattern"]})(\s*)(.*?)\s*$', comment) if comment_segments: pre_marker_text, _, post_marker_whitespace, comment = comment_segments.groups() pre_marker_length = len(pre_marker_text) diff --git a/main.py b/main.py index 845d82b..d687cb4 100644 --- a/main.py +++ b/main.py @@ -76,7 +76,7 @@ def process_diff(diff, client=Client(), insert_issue_urls=False, parser=TodoPars if line_number < len(file_lines): # Duplicate the line to retain the comment syntax. old_line = file_lines[line_number] - remove = fr'(?i:{re.escape(raw_issue.identifier)}).*{re.escape(raw_issue.title)}' + remove = fr'(?i:{re.escape(raw_issue.identifier)}).*{re.escape(raw_issue.title)}.*?(\r|\r\n|\n)?$' insert = f'Issue URL: {client.get_issue_url(new_issue_number)}' new_line = re.sub('^.*'+remove, raw_issue.prefix + insert, old_line) # make sure the above operation worked as intended