ardagnir / athame

Full vim for your shell (bash, zsh, gdb, python, etc)
GNU General Public License v3.0
1.63k stars 34 forks source link

Ctrl-c not working correctly in python #31

Closed infokiller closed 6 years ago

infokiller commented 8 years ago

Without athame, the behaviour of these keys is as following:

With athame in insert mode:

Using IPython 4.0.1.

Thanks!

ardagnir commented 8 years ago

Tab is also broken in Python shell, but I'm still looking into why. I haven't used iPython; I'll have to see what is wrong with Ctrl-c. Thanks for letting me know! On May 29, 2016 5:03 AM, "infokiller" notifications@github.com wrote:

Without athame, the behaviour of these keys is as following:

  • Tab: inserts a tab
  • Ctrl-c: cancels the current line edit and KeyboardInterrupt is printed

With athame in insert mode:

  • Tab: in the beginning of the line it inserts a tab correctly, but seem to think that a new line is edited- the -- INSERT -- is gone until I type anything. When I start typing anything after the tab it goes into insert mode again but starts from the beginning of the line, ignoring the tab (like cc was used in vim).
  • Ctrl-c: if this is the first thing I do on a new line, before the -- INSERT -- indicator appears, it works as expected. However after the indicator appears it seems to ignore the Ctrl-c untill I press return, at which point I get the KeyboardInterrupt message.

Using IPython 4.0.1.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ardagnir/athame/issues/31, or mute the thread https://github.com/notifications/unsubscribe/ACUkPkX8h_dCFJfW-RRvGYtvc0yhQQqXks5qGVZfgaJpZM4IpPza .

ardagnir commented 8 years ago

Tab should be fixed now in python and ipython. Control C is still broken.

ardagnir commented 7 years ago

Changing to just cover python because ipython now uses prompt_toolkit instead of readline (covered in https://github.com/ardagnir/athame/issues/35).

The reason this is non-trivial to fix is that: 1) control C sends a SIGINT instead of a keypress. This signal is handled by python. 2) python doesn't tell readline about signals like bash does, so athame can't just use readline code to tell if it got the signal. 3) python doesn't give control back to readline until it gets another keypress, so if we give control back to it after every key like normal readline, we break CursorHold, imaps timing out, anything async, etc among other problems.

ardagnir commented 6 years ago

Fixed in 1.0 branch.