mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
refactor: sort new file mentions before confirmation
This commit is contained in:
parent
41a43fc313
commit
e45def7a98
2 changed files with 4 additions and 4 deletions
|
@ -1327,7 +1327,7 @@ class Coder:
|
||||||
|
|
||||||
added_fnames = []
|
added_fnames = []
|
||||||
group = ConfirmGroup(new_mentions)
|
group = ConfirmGroup(new_mentions)
|
||||||
for rel_fname in new_mentions:
|
for rel_fname in sorted(new_mentions):
|
||||||
if self.io.confirm_ask(f"Add {rel_fname} to the chat?", group=group):
|
if self.io.confirm_ask(f"Add {rel_fname} to the chat?", group=group):
|
||||||
self.add_rel_fname(rel_fname)
|
self.add_rel_fname(rel_fname)
|
||||||
added_fnames.append(rel_fname)
|
added_fnames.append(rel_fname)
|
||||||
|
|
|
@ -199,13 +199,13 @@ class TestCoder(unittest.TestCase):
|
||||||
coder = Coder.create(self.GPT35, None, io)
|
coder = Coder.create(self.GPT35, None, io)
|
||||||
|
|
||||||
# Mock get_file_mentions to return two file names
|
# Mock get_file_mentions to return two file names
|
||||||
coder.get_file_mentions = MagicMock(return_value=["file1.txt", "file2.txt"])
|
coder.get_file_mentions = MagicMock(return_value=set(["file1.txt", "file2.txt"]))
|
||||||
|
|
||||||
# Mock confirm_ask to return False for the first call and True for the second
|
# Mock confirm_ask to return False for the first call and True for the second
|
||||||
io.confirm_ask = MagicMock(side_effect=[False, True])
|
io.confirm_ask = MagicMock(side_effect=[False, True, True])
|
||||||
|
|
||||||
# First call to check_for_file_mentions
|
# First call to check_for_file_mentions
|
||||||
coder.check_for_file_mentions("Please check file1.txt and file2.txt")
|
coder.check_for_file_mentions("Please check file1.txt for the info")
|
||||||
|
|
||||||
# Assert that confirm_ask was called twice
|
# Assert that confirm_ask was called twice
|
||||||
self.assertEqual(io.confirm_ask.call_count, 2)
|
self.assertEqual(io.confirm_ask.call_count, 2)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue