TerminalInteractiveShell.editing_mode inconsitency #10680

Open
yarko opened this Issue Jun 27, 2017 · 4 comments

Comments

Projects
None yet
4 participants

yarko commented Jun 27, 2017

I'm just going to document this for the moment:

ipython 6.1.0
python:

  • problem shows:
    • 3.5.2
    • 3.6.2b2 (and I think 3.6.1)
    • 3.7.0dev [Python 3.7.0a0 (heads/master:a7874c7, Jun 26 2017, 21:58:56)]

O/S:
ubuntu 16.04
windows 10

$HOME/.ipython/profile_default/ipython_config.py settings:

c.TerminalInteractiveShell.editing_mode = 'vi'

Behavior:

with some history established:

  • move up history w/ editor (e.g. [ESC]k)
  • do some editing action on the line (no mods necessary - i [ESC] is sufficient)
  • attempt to move to a different line in history (any line)
    • e.g. attempt motion k
    • also search /foobar: can select searched line, but no motion from result (except original line)
  • expected:
    • motion through history
  • actual:
    • stuck on current line
Owner

Carreau commented Jun 29, 2017

Thanks for the details report. We'll have to dig through it, but it might be a prompt_toolkit issue and a fix might be needed upstream (if not already fixed on master).

Owner

takluyver commented Jul 3, 2017

Ping @jonathanslenders - IIRC we just pass the specified editing mode through to prompt_toolkit.

Contributor

jonathanslenders commented Jul 3, 2017

Hi everyone, I noticed that IPython has history_search enabled. (https://github.com/ipython/ipython/blob/d2b29fbc83a01c9b9f6650c10c8549974ed1ea71/IPython/terminal/interactiveshell.py#L272)

This means that when you type something the history is filtered on this input string. Like the readline history-search-forward and history-search-backward commands. Typing import<up> should go through the history to the last import statement.

Whether or not you want to make this configurable is up to you. But I noticed that there was a bug in prompt_toolkit as well regarding this. It did consider all the input text when you started editing, rather than only the text before the cursor. jonathanslenders/python-prompt-toolkit@2fe952a

Could you test again with the latest prompt_toolkit, master branch?

yarko commented Jul 9, 2017 edited

thanks @jonathanslenders - sorry for my delay in getting back to this.

I use ipython in my venv's, so I uninstalled prompt-toolkit, cloned https://github.com/jonathanslenders/python-prompt-toolkit and python setup.py develop installed it, with your change mentioned above.

It changed things, so here's how:

Behavior:

with some history established:

  • move up history w/ editor (e.g. [ESC]k)
  • do some editing action on the line (no mods necessary - i [ESC] is sufficient)
  • attempt to move to a different line in history (any line)
    • e.g. attempt motion k
    • also search /foobar: can select searched line, but no motion from result (except original line)
  • expected:
    • motion through history
  • actual (remember - I'm using vi mode):
    • Before @jonathanslenders change:
      • stuck on current line
    • After @jonathanslenders change (action, below, on moved-to line):
      • when no editing (e.g. {{some line motion}}; i[ESC]):
        • motion through history (now) works
      • when any changes (now seems inconsistent):
        • with example history line traveled to: a = 1:
          • A+[ESC]u or A+[ESC]x:
            • now motion goes to lines only beginning with 'a' (not expected);
            • [EDIT]: also checked that it's first character on the line (it is), i.e. with this in history:
              • print('first')
              • p = 1
              • print('second')
              • Abandoning an edit on the last print does include the p = 1 lines in history motion.
            • search-through-history from this line (i.e. [ESC]/) works, finds other lines (ok);
          • A + 2[ESC] (abandoned changed):
            • now upward motion goes to beginning of current line only (I'd expect abandon edit, but...);
            • search still works (ok);
            • other expected behaviors work, e.g.: dd (to clear line) or [CTL]C to force abandon;

I am thinking the remaining "bug" is the 'abandoned edit' and unchanged line, marked (not expected).

Your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment