mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 18:25:00 +00:00
feat: Add raw completer for cmd_read_only command
This commit is contained in:
parent
ee4de6bd1c
commit
b930a1db40
1 changed files with 27 additions and 2 deletions
|
@ -8,6 +8,7 @@ from pathlib import Path
|
||||||
|
|
||||||
import pyperclip
|
import pyperclip
|
||||||
from PIL import Image, ImageGrab
|
from PIL import Image, ImageGrab
|
||||||
|
from prompt_toolkit.completion import PathCompleter
|
||||||
|
|
||||||
from aider import models, prompts, voice
|
from aider import models, prompts, voice
|
||||||
from aider.format_settings import format_settings
|
from aider.format_settings import format_settings
|
||||||
|
@ -574,8 +575,32 @@ class Commands:
|
||||||
fname = f'"{fname}"'
|
fname = f'"{fname}"'
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
def completions_read_only(self):
|
def completions_raw_read_only(self, document, complete_event):
|
||||||
return self.completions_add()
|
# Extract the part of the input after the command
|
||||||
|
text = document.text[len("/read-only"):].lstrip()
|
||||||
|
|
||||||
|
# Create a PathCompleter
|
||||||
|
path_completer = PathCompleter(
|
||||||
|
only_directories=False,
|
||||||
|
expanduser=True,
|
||||||
|
get_paths=lambda: [self.coder.root],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Get completions from the PathCompleter
|
||||||
|
completions = path_completer.get_completions(
|
||||||
|
document.replace(text=text),
|
||||||
|
complete_event
|
||||||
|
)
|
||||||
|
|
||||||
|
# Yield the completions
|
||||||
|
for completion in completions:
|
||||||
|
# Adjust the start position to account for the command
|
||||||
|
yield Completion(
|
||||||
|
completion.text,
|
||||||
|
start_position=completion.start_position - len(document.text) + len(text),
|
||||||
|
display=completion.display,
|
||||||
|
display_meta=completion.display_meta
|
||||||
|
)
|
||||||
|
|
||||||
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