selection mode highlighting is very confusing in my terminal
See original GitHub issueThis is with gnome-terminal on Linux, using ipython.
Suppose I have this text:
here is the mark: _ more text
I place my cursor on top of the underscore, and hit control-space, and then move my cursor around to perform various experiments:
What I see after moving my cursor to the left a bit (using [x]
to indicate that x
is displayed in reverse-font):
here is the mark[:][ ][_] more text
What this means: the text k: _
is selected, and will be cut if I hit control-W. Notice that k
is not highlighted.
What I see immediately after hitting control-space, before moving the cursor anywhere:
here is the mark: _ more text
i.e., the cursor has disappeared, and nothing is highlighted. What this means: the text _
is selected, and will be cut if I hit control-W. (NB that in addition to being visually confusing, this is subtly incompatible with what emacs does, cf. #323 – for emacs, immediately after hitting control-space, the mark and point are both immediately to the left of the character that’s under the cursor, and so hitting control-W cuts the empty string.)
What I see after moving the cursor one space in either direction:
here is the mark: [_] more text
What this means: either the text _
(space and the following underscore) or the text _
(underscore and the following space) is selected and will be cut if hit control-W. These cases are visually indistinguishable.
What I see after placing the cursor top of the t
at the end of the line:
here is the mark: [_][ ][m][o][r][e][ ][t][e][x]t
What I see after moving the cursor one more space to the right, so that it’s actually at the end of the line:
here is the mark: [_][ ][m][o][r][e][ ][t][e][x][t][ ]
i.e. moving the cursor one space to the right apparently causes two extra highlighted spaces to appear. AFAICT these two cases are identical in terms of what’s selected: in both cases, hitting control-W will cut the text _ more text
(which is not what’s visually selected in either case!)
I think maybe there are two underlying bugs here:
- prompt-toolkit should follow emacs and interpreter the mark and point as being placed at the space in between characters, to the left of where the cursor is when control-Space is pressed (for mark) and where the cursor is currently (for point)
- prompt-toolkit’s attempt to highlight the selected region by reversing the text colors collides with gnome-terminal’s using this same approach to show the cursor. It would be better if prompt toolkit used some more distinctive mechanism for showing the highlight, like perhaps the light grey background that it uses for completion drop-downs.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
This fix has been merged: https://github.com/jonathanslenders/python-prompt-toolkit/pull/619 I think it should be fine now. Please let me know if I miss something. It doesn’t do the whole kill-ring thing yet, but that’s a different issue.
Since this is somewhat of a backwards incompatible change, should this be considered for 2.0?