diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py
index fb725848..5fc45619 100644
--- a/pr_agent/tools/pr_code_suggestions.py
+++ b/pr_agent/tools/pr_code_suggestions.py
@@ -325,7 +325,7 @@ class PRCodeSuggestions:
pr_body += "
"
header = f"Suggestions"
- delta = 77
+ delta = 75
header += " " * delta
pr_body += f""" | {header} |
"""
pr_body += """"""
diff --git a/pr_agent/tools/pr_description.py b/pr_agent/tools/pr_description.py
index ef64f515..bbe53fca 100644
--- a/pr_agent/tools/pr_description.py
+++ b/pr_agent/tools/pr_description.py
@@ -363,7 +363,7 @@ class PRDescription:
try:
pr_body += ""
header = f"Relevant files"
- delta = 77
+ delta = 75
# header += " " * delta
pr_body += f""" | {header} |
"""
pr_body += """"""
@@ -454,6 +454,10 @@ def insert_br_after_x_chars(text, x=70):
if i < len(lines) - 1:
words[-1] += "
"
+ def count_chars_without_html(string):
+ no_html_string = re.sub('<[^>]+>', '', string)
+ return len(no_html_string)
+
new_text = []
is_inside_code = False
current_length = 0
@@ -461,12 +465,13 @@ def insert_br_after_x_chars(text, x=70):
is_saved_word = False
if word == "" or word == "
" or word == "" or word == "
":
is_saved_word = True
- if word == "":
+ if "" in word:
is_inside_code = True
- elif word == "
":
+ if "
" in word:
is_inside_code = False
- if not is_saved_word and (current_length + len(word) > x):
+ len_word = count_chars_without_html(word)
+ if not is_saved_word and (current_length + len_word > x):
if is_inside_code:
new_text.append("
")
else:
@@ -475,7 +480,7 @@ def insert_br_after_x_chars(text, x=70):
new_text.append(word + " ")
if not is_saved_word:
- current_length += len(word) + 1 # Add 1 for the space
+ current_length += len_word + 1 # Add 1 for the space
if word == "" or word == "
":
current_length = 0
diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py
index 9e662a76..72d34656 100644
--- a/tests/unittest/test_convert_to_markdown.py
+++ b/tests/unittest/test_convert_to_markdown.py
@@ -98,13 +98,11 @@ class TestConvertToMarkdown:
class TestBR:
def test_br1(self):
- file_change_description = '- Created a new class `ColorPaletteResourcesCollection` in the namespace `Avalonia.Themes.Fluent`.\n- The class extends `AvaloniaDictionary` and implements `IResourceProvider`.\n- The class includes methods for handling theme variants, resource retrieval, owner management, and property change events.'
+ file_change_description = '- Imported `FilePatchInfo` and `EDIT_TYPE` from `pr_agent.algo.types` instead of `pr_agent.git_providers.git_provider`.'
file_change_description_br = insert_br_after_x_chars(file_change_description)
- expected_output=('Created a new class ColorPaletteResourcesCollection
in the namespace '
- 'Avalonia.Themes.Fluent
.
The class extends AvaloniaDictionary'
- 'ColorPaletteResources>
and implements
IResourceProvider'
- '
.
The class includes methods for handling theme variants, resource
'
- 'retrieval, owner management, and property change events.')
+ expected_output = ('Imported FilePatchInfo
and EDIT_TYPE
from '
+ 'pr_agent.algo.types
instead
of '
+ 'pr_agent.git_providers.git_provider
.')
assert file_change_description_br == expected_output
# print("-----")
# print(file_change_description_br)
@@ -113,9 +111,10 @@ class TestBR:
file_change_description = ('- Created a - new -class `ColorPaletteResourcesCollection ColorPaletteResourcesCollection '
'ColorPaletteResourcesCollection ColorPaletteResourcesCollection`')
file_change_description_br = insert_br_after_x_chars(file_change_description)
- expected_output = ('Created a - new -class ColorPaletteResourcesCollection '
- '
ColorPaletteResourcesCollection ColorPaletteResourcesCollection '
- '
ColorPaletteResourcesCollection
')
+ expected_output = ('Created a - new -class ColorPaletteResourcesCollection
'
+ 'ColorPaletteResourcesCollection ColorPaletteResourcesCollection
'
+ 'ColorPaletteResourcesCollection
')
assert file_change_description_br == expected_output
# print("-----")
- # print(file_change_description_br)
\ No newline at end of file
+ # print(file_change_description_br)
+