mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
feat: sort completions in completions_raw_read_only method
This commit is contained in:
parent
50f88a8d28
commit
0c743ce8e8
1 changed files with 24 additions and 10 deletions
|
@ -603,27 +603,41 @@ class Commands:
|
|||
# Adjust the start_position to replace all of 'after_command'
|
||||
adjusted_start_position = -len(after_command)
|
||||
|
||||
# Collect all completions
|
||||
all_completions = []
|
||||
|
||||
# Iterate over the completions and modify them
|
||||
for completion in path_completer.get_completions(new_document, complete_event):
|
||||
quoted_text = self.quote_fname(after_command + completion.text)
|
||||
yield Completion(
|
||||
text=quoted_text,
|
||||
start_position=adjusted_start_position,
|
||||
display=completion.display,
|
||||
style=completion.style,
|
||||
selected_style=completion.selected_style,
|
||||
all_completions.append(
|
||||
Completion(
|
||||
text=quoted_text,
|
||||
start_position=adjusted_start_position,
|
||||
display=completion.display,
|
||||
style=completion.style,
|
||||
selected_style=completion.selected_style,
|
||||
)
|
||||
)
|
||||
|
||||
# Add completions from the 'add' command
|
||||
add_completions = self.completions_add()
|
||||
for completion in add_completions:
|
||||
if after_command in completion:
|
||||
yield Completion(
|
||||
text=completion,
|
||||
start_position=adjusted_start_position,
|
||||
display=completion,
|
||||
all_completions.append(
|
||||
Completion(
|
||||
text=completion,
|
||||
start_position=adjusted_start_position,
|
||||
display=completion,
|
||||
)
|
||||
)
|
||||
|
||||
# Sort all completions based on their text
|
||||
sorted_completions = sorted(all_completions, key=lambda c: c.text)
|
||||
|
||||
# Yield the sorted completions
|
||||
for completion in sorted_completions:
|
||||
yield completion
|
||||
|
||||
def completions_add(self):
|
||||
files = set(self.coder.get_all_relative_files())
|
||||
files = files - set(self.coder.get_inchat_relative_files())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue