dooit-org / dooit

An awesome TUI todo manager
MIT License
2.1k stars 97 forks source link

[BUG] IndexError: list index out of range #143

Closed GrimPixel closed 1 year ago

GrimPixel commented 1 year ago

Describe the bug 🐛 A clear and concise description of what the bug is.

To Reproduce 🐣 Just typed some keys I forgot, with some Arabic input.

Expected behavior 🤔 Nothing wrong happens.

Screenshots 🧐

Desktop (please complete the following information): 🤖

Additional context 📝

╭──────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────╮
│ /home/user/venv/lib/python3.11/site-packages/dooit/ui/screens/index.py:63 in on_key                                        │
│                                                                                                                            │
│    60 │   │   │   return await self.query_one(Searcher).keypress(key)                                                      │
│    61 │   │                                                                                                                │
│    62 │   │   visible_focused = [i for i in self.query(".focus") if i.display][0]                                          │
│ ❱  63 │   │   await visible_focused.keypress(key)                                                                          │
│    64 │                                                                                                                    │
│    65 │   async def clear_right(self) -> None:                                                                             │
│    66 │   │   try:                                                                                                         │
│                                                                                                                            │
│ ╭───────────────────────────────────────────────────── locals ──────────────────────────────────────────────────────╮      │
│ │           event = Key(key='enter', character='\r', name='enter', is_printable=False, aliases=['enter', 'ctrl+m']) │      │
│ │             key = 'enter'                                                                                         │      │
│ │            self = MainScreen(name='main')                                                                         │      │
│ │ visible_focused = TodoTree(id='Tree-workspace_8758079a-caaa-4067-8109-017502b92d0c')                              │      │
│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯      │
│                                                                                                                            │
│ /home/user/venv/lib/python3.11/site-packages/dooit/ui/widgets/tree.py:488 in keypress                                      │
│                                                                                                                            │
│   485 │   │   if self.current_visible_widget and hasattr(                                                                  │
│   486 │   │   │   self.current_visible_widget, "keypress"                                                                  │
│   487 │   │   ):                                                                                                           │
│ ❱ 488 │   │   │   return await getattr(self.current_visible_widget, "keypress")(key)                                       │
│   489 │   │                                                                                                                │
│   490 │   │   if self.current and self.current._is_editing():                                                              │
│   491 │   │   │   return await self.current.keypress(key)                                                                  │
│                                                                                                                            │
│ ╭───────────────────────────────── locals ──────────────────────────────────╮                                              │
│ │  key = 'enter'                                                            │                                              │
│ │ self = TodoTree(id='Tree-workspace_8758079a-caaa-4067-8109-017502b92d0c') │                                              │
│ ╰───────────────────────────────────────────────────────────────────────────╯                                              │
│                                                                                                                            │
│ /home/user/venv/lib/python3.11/site-packages/dooit/ui/widgets/base.py:41 in keypress                                       │
│                                                                                                                            │
│   38 │   │   │   │   if bind.check_for_cursor and not self.is_cursor_available:                                            │
│   39 │   │   │   │   │   return                                                                                            │
│   40 │   │   │   │                                                                                                         │
│ ❱ 41 │   │   │   │   res = await func(*bind.params)                                                                        │
│   42 │   │   │   │   if isinstance(res, Result) and res.message:                                                           │
│   43 │   │   │   │   │   self.post_message(Notify(res.text()))                                                             │
│   44                                                                                                                       │
│                                                                                                                            │
│ ╭────────────────────────────────────────────────────── locals ───────────────────────────────────────────────────────╮    │
│ │ bind = <dooit.utils.keybinder.Bind object at 0x7f8c744b92d0>                                                        │    │
│ │ func = <bound method SearchMenu.stop of SearchMenu(id='SearchMenu-workspace_8758079a-caaa-4067-8109-017502b92d0c')> │    │
│ │  key = 'enter'                                                                                                      │    │
│ │ self = SearchMenu(id='SearchMenu-workspace_8758079a-caaa-4067-8109-017502b92d0c')                                   │    │
│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯    │
│                                                                                                                            │
│ /home/user/venv/lib/python3.11/site-packages/dooit/ui/widgets/search_menu.py:55 in stop                                    │
│                                                                                                                            │
│   52 │   async def stop(self) -> None:                                                                                     │
│   53 │   │   from dooit.ui.widgets.tree import Tree                                                                        │
│   54 │   │                                                                                                                 │
│ ❱ 55 │   │   if self.current_option:                                                                                       │
│   56 │   │   │   query = (                                                                                                 │
│   57 │   │   │   │   "WorkspaceTree"                                                                                       │
│   58 │   │   │   │   if self.children_type == "workspace"                                                                  │
│                                                                                                                            │
│ ╭───────────────────────────────────── locals ──────────────────────────────────────╮                                      │
│ │ self = SearchMenu(id='SearchMenu-workspace_8758079a-caaa-4067-8109-017502b92d0c') │                                      │
│ │ Tree = <class 'dooit.ui.widgets.tree.Tree'>                                       │                                      │
│ ╰───────────────────────────────────────────────────────────────────────────────────╯                                      │
│                                                                                                                            │
│ /home/user/venv/lib/python3.11/site-packages/dooit/ui/widgets/search_menu.py:21 in current_option                          │
│                                                                                                                            │
│   18 │                                                                                                                     │
│   19 │   @property                                                                                                         │
│   20 │   def current_option(self) -> Optional[str]:                                                                        │
│ ❱ 21 │   │   return self.visible_options[self.current][1]                                                                  │
│   22 │                                                                                                                     │
│   23 │   def refresh_options(self) -> None:                                                                                │
│   24 │   │   self.filter = []                                                                                              │
│                                                                                                                            │
│ ╭───────────────────────────────────── locals ──────────────────────────────────────╮                                      │
│ │ self = SearchMenu(id='SearchMenu-workspace_8758079a-caaa-4067-8109-017502b92d0c') │                                      │
│ ╰───────────────────────────────────────────────────────────────────────────────────╯                                      │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: list index out of range
github-actions[bot] commented 1 year ago

Did we solve your problem? Glad we could help!

Consider sponsoring my work through github sponsors :smile: – @kraanzu

kraanzu commented 1 year ago

Hey! This was an error because you started search mode and dooit tried to find an item but it couldn't find it because the list was empty

You'd have typed '/' which started the search mode

kraanzu commented 1 year ago

It looks like PyPi has some extra authentication stuff that prevented it from publishing

You can install the latest version using this command:

pip install git+https://github.com/kraanzu/dooit.git