History navigation breaks in qtconsole #2485

aweinstein opened this Issue Oct 12, 2012 · 3 comments


None yet
4 participants

I observe that, under some particular conditions, the behavior of the history navigation in the qtconsole breaks.

Typically, if I type a letter, say 'a', and then press the up arrow key, IPython only shows the items in the history that start with that letter. However, under some conditions this behavior stop working.

The phenomenon can be observed by typing the following in a qtconsole instance. (I am just showing what I type, not the IPython output):

a=1 'Enter'
b=2 'Enter'
b C-p C-a C-k a C-p

Here 'Enter' corresponds to pressing the enter key, and C-x corresponds to pressing Ctrl and the 'x' key.

In this example, I expect that, after pressing C-p the last time, I should see 'a=1' in the prompt (that's what I see after doing this in a terminal IPython instance), however, I see 'b=2' in the prompt.

I have the same issue, when I do ctrl-k on part of line, prefix history navigating no longer works


minrk commented Jan 20, 2013

If either of you could test #2819, I would appreciate the feedback.

@minrk #2819 fix the behavior described in this issue. However, the following doesn't work:

a = 1 'Enter'
b = 2 'Enter'
[i for i in range(3)] 'Enter'
C-p C-p C-a C-k
[ C-p

Instead of seeing [i for i in range(3)], I see a = 2.

@Carreau Carreau closed this in eab1495 Feb 5, 2013

@minrk minrk added this to the 1.0 milestone Mar 26, 2014

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

Merge pull request #2819 from minrk/qt_hist_up
tweak history prefix search (up/^p) in qtconsole

moving the cursor around the line could result in weird inconsistencies in the prefix.

This simplifies the logic by always using the cursor position to set the history prefix, and better determine when the history prefix has actually changed.

also fixes a small typo where a while-loop was always checking the initial value, rather than the iterator, which could result in an IndexError at the end of the history.

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