jupyter / jupyter_console

Jupyter Terminal Console
http://jupyter-console.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
248 stars 146 forks source link

Fix vi input mode enum bug #289

Open jsr-p opened 1 year ago

jsr-p commented 1 year ago

With the vi options

c.ZMQTerminalInteractiveShell.editing_mode = 'vi'
c.ZMQTerminalInteractiveShell.prompt_includes_vi_mode = True

specified in jupyter_console_config.py, the terminal output, in all vi modes, looks like:

2023-03-30T09:45:19,921232808+02:00

The reason for the error is found here. The Enum self.pt_cli.app.vi_state.input_mode is passed into the str function, which only shows the the enum name and member name, not the value of the member, cf the Python docs. The Enum used is the InputMode.INSERT Enum from prompt_toolkit defined here. Applying the str function returns InputMode.INSERT and subsetting this with [3:6] yields the utM shown in the terminal screenshot.

This pull requests fixes this issue by simply removing the application of the str function before subsetting the enum member. This is also what is done in the IPython repo here.