Suggestion autocomplete function now returns full suggestion, Textual calculates suffix

This commit is contained in:
Darren Burns
2022-05-20 15:29:24 +01:00
parent 4c03fb0348
commit 4a4841d0db
3 changed files with 19 additions and 12 deletions

View File

@@ -42,13 +42,14 @@ class FileTable(Widget):
grid = Table.grid()
grid.add_column()
for file in self.filtered_files:
file_text = Text(" " + file.name)
file_text.highlight_regex(self.filter, "black on yellow")
file_text = Text(f" {file.name}")
if self.filter:
file_text.highlight_regex(self.filter, "black on yellow")
grid.add_row(file_text)
return grid
class FileSearchApp(App[str]):
class FileSearchApp(App):
dark = True
def on_mount(self) -> None:

View File

@@ -24,7 +24,7 @@ def word_autocompleter(value: str) -> str | None:
# word completions
for word in words:
if word.startswith(value):
return word[len(value) :]
return word
return None