From 59ddd744827a6b937118475273af010ea7d279e1 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Wed, 24 Jul 2024 14:26:43 -0300 Subject: Feat: adds update_list() --- packages/finder/main.py | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/packages/finder/main.py b/packages/finder/main.py index f562322..f1fca16 100644 --- a/packages/finder/main.py +++ b/packages/finder/main.py @@ -53,20 +53,20 @@ class FinderMain(): return True def change(self, _): - # Text for the buffer - text = self.format(self.searcher.filter(self.input_field.text)) - - # This only works when the buffer is read-write - #self.output_buffer.text = text - - # For read-only buffers - self.output_buffer.set_document(Document(text), bypass_readonly=True) + self.update_list(self.searcher.filter(self.input_field.text)) def open(self): item = self.output_buffer.document.current_line self.opener.open(os.path.join(self.path, item)) + def update_list(self, items): + # This only works when the buffer is read-write + #self.output_buffer.text = self.format(items) + + # For read-only buffers + self.output_buffer.set_document(Document(self.format(items)), bypass_readonly=True) + def bindings(self): self.keybindings = KeyBindings() @@ -168,16 +168,11 @@ class FinderMain(): from .plugin.searcher.file.name import FinderPluginFileNameSearcher from .plugin.opener.file.xdg import FinderPluginFileXdgOpener - self.searcher = FinderPluginFileNameSearcher(self.path) - self.opener = FinderPluginFileXdgOpener() - self.state['loading'] = False - text = self.format(await self.searcher.finder()) + self.searcher = FinderPluginFileNameSearcher(self.path) + self.opener = FinderPluginFileXdgOpener() + self.state['loading'] = False - # This only works when the buffer is read-write - #self.output_buffer.text = text - - # For read-only buffers - self.output_buffer.set_document(Document(text), bypass_readonly=True) + self.update_list(await self.searcher.finder()) def run(self): return asyncio.run(self.main()) -- cgit v1.2.3