akashnag/ash

[BUG] Ash crash on window click

Closed this issue · 1 comments

Whenever I click in the opened ash window it crashes. This seems to be caused by clicking on a not-yet-created-line. If I create 5 lines (hitting Enter), I can jump between them freely by clicking on them.

The KeyError is dependent on the row you clicked.

To Reproduce

  1. Install ash via suggested
    sudo pip3 install ash-editor
  2. Add it to path
  3. Start ash
  4. Click in the ash window where there are no lines
  5. Observe the crash

Expected behavior
Not to crash

Desktop (please complete the following information):

  • OS: Arch 5.14.6-arch1-1
  • Version: 0.1.0.dev7
  • Shell: zsh

Additional context
Using bash produces the same result

Here is the traceback. The KeyError is different every time

Traceback (most recent call last):
  File "/usr/bin/ash", line 33, in <module>
    sys.exit(load_entry_point('ash-editor==0.1.0.dev7', 'console_scripts', 'ash')())
  File "/usr/lib/python3.9/site-packages/ash/ash_main.py", line 16, in run
    app.run()
  File "/usr/lib/python3.9/site-packages/ash/main.py", line 112, in run
    ret_code = curses.wrapper(self.app_main)
  File "/usr/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/lib/python3.9/site-packages/ash/main.py", line 182, in app_main
    self.main_window.show(welcome_msg)          # this call returns when main_window() is closed
  File "/usr/lib/python3.9/site-packages/ash/gui/topLevelWindow.py", line 131, in show
    w.on_click(ry,rx)
  File "/usr/lib/python3.9/site-packages/ash/gui/editor.py", line 340, in on_click
    curpos = self.screen.get_curpos_after_click(y, x, self.buffer.lines, self.width, self.tab_size, self.word_wrap, self.hard_wrap)
  File "screen.pyx", line 702, in ash.core.screen.Screen.get_curpos_after_click
  File "screen.pyx", line 387, in ash.core.screen.Screen.translate_rendered_curpos_to_real_curpos
KeyError: 25```

I believe this issue was fixed. Can you check if the problem persists with the latest nightly build?