mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +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,26 +603,40 @@ class Commands:
|
||||||
# Adjust the start_position to replace all of 'after_command'
|
# Adjust the start_position to replace all of 'after_command'
|
||||||
adjusted_start_position = -len(after_command)
|
adjusted_start_position = -len(after_command)
|
||||||
|
|
||||||
|
# Collect all completions
|
||||||
|
all_completions = []
|
||||||
|
|
||||||
# Iterate over the completions and modify them
|
# Iterate over the completions and modify them
|
||||||
for completion in path_completer.get_completions(new_document, complete_event):
|
for completion in path_completer.get_completions(new_document, complete_event):
|
||||||
quoted_text = self.quote_fname(after_command + completion.text)
|
quoted_text = self.quote_fname(after_command + completion.text)
|
||||||
yield Completion(
|
all_completions.append(
|
||||||
|
Completion(
|
||||||
text=quoted_text,
|
text=quoted_text,
|
||||||
start_position=adjusted_start_position,
|
start_position=adjusted_start_position,
|
||||||
display=completion.display,
|
display=completion.display,
|
||||||
style=completion.style,
|
style=completion.style,
|
||||||
selected_style=completion.selected_style,
|
selected_style=completion.selected_style,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Add completions from the 'add' command
|
# Add completions from the 'add' command
|
||||||
add_completions = self.completions_add()
|
add_completions = self.completions_add()
|
||||||
for completion in add_completions:
|
for completion in add_completions:
|
||||||
if after_command in completion:
|
if after_command in completion:
|
||||||
yield Completion(
|
all_completions.append(
|
||||||
|
Completion(
|
||||||
text=completion,
|
text=completion,
|
||||||
start_position=adjusted_start_position,
|
start_position=adjusted_start_position,
|
||||||
display=completion,
|
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):
|
def completions_add(self):
|
||||||
files = set(self.coder.get_all_relative_files())
|
files = set(self.coder.get_all_relative_files())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue