mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-14 22:17:35 +00:00
Fix edge case in insert_text_at_position when inserting in line beyond actual content
(insertion coordinates were not adjusted to true end coordinates)
This commit is contained in:
1 parent
d4e99dc003
commit
c80d76abe9
2 files changed
+20
-1
No files matched your search
@@ -32,3 +32,19 @@ class TestTextUtils:
|
||||
assert TextUtils.get_index_from_line_col(self.TEXT, 0, 1) == 1
|
||||
assert TextUtils.get_index_from_line_col(self.TEXT, 1, 1) == 3 + 1 + 1
|
||||
assert TextUtils.get_index_from_line_col(self.TEXT, 2, 1) == 3 + 1 + 3 + 2 + 1
|
||||
|
||||
def test_insert_text_at_index(self):
|
||||
insertion = "XXX"
|
||||
new_text, l, c = TextUtils.insert_text_at_position(self.TEXT, 0, 1, insertion)
|
||||
assert (l, c) == (0, 1 + len(insertion))
|
||||
assert new_text.startswith("0XXX12")
|
||||
|
||||
def test_insert_text_in_next_line_beyond_content(self):
|
||||
"""
|
||||
Test inserting text at a line index 1 beyond the actual number of lines.
|
||||
This case is specifically handled as an edge case in the implementation.
|
||||
"""
|
||||
insertion = "XXX"
|
||||
new_text, l, c = TextUtils.insert_text_at_position(self.TEXT, 4, 0, insertion)
|
||||
assert (l, c) == (4, len(insertion))
|
||||
assert new_text == self.TEXT + "\n" + insertion
|
||||
Reference in new issue
Block a user