mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
feat: Simplify completions_raw_read_only method
This commit is contained in:
parent
38d03bca09
commit
1f56118c99
1 changed files with 4 additions and 15 deletions
|
@ -580,22 +580,11 @@ class Commands:
|
||||||
return fname
|
return fname
|
||||||
|
|
||||||
def completions_raw_read_only(self, document, complete_event):
|
def completions_raw_read_only(self, document, complete_event):
|
||||||
# Get the text before the cursor and strip leading spaces
|
# Get the text before the cursor
|
||||||
text = document.text_before_cursor.lstrip()
|
text = document.text_before_cursor
|
||||||
|
|
||||||
# Identify the command and extract text after it
|
# Skip the first word and the space after it
|
||||||
command = "/read-only"
|
after_command = ' '.join(text.split()[1:])
|
||||||
if text.startswith("/"):
|
|
||||||
# Find the longest matching prefix of "/read-only"
|
|
||||||
for i in range(len(command), 0, -1):
|
|
||||||
if text.startswith(command[:i]):
|
|
||||||
after_command = text[i:].lstrip()
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# If no prefix matches, return no completions
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
after_command = text
|
|
||||||
|
|
||||||
# Create a new Document object with the text after the command
|
# Create a new Document object with the text after the command
|
||||||
new_document = Document(after_command, cursor_position=len(after_command))
|
new_document = Document(after_command, cursor_position=len(after_command))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue