[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-readline] [PATCH] fix cursor position after completion
From: |
Miroslav Lichvar |
Subject: |
[Bug-readline] [PATCH] fix cursor position after completion |
Date: |
Thu, 6 Dec 2007 18:02:08 +0100 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi,
there is a bug in cursor placement after completion if the following
conditions are met:
- multibyte locale is used
- prompt has invisible characters
- number of characters after the cursor is greater than number of
invisible characters in the prompt
Steps to reproduce the problem in bash can be found here:
https://bugzilla.redhat.com/show_bug.cgi?id=249987
It's caused by line 1048 in redisplay()
_rl_col_width(&visible_line[pos], 0, nleft)
nleft is nonzero, but visible_line[pos] is empty string and
_rl_col_width returns negative number.
As the functionality around this line seems to be implemented also in
_rl_move_cursor_relative which is called afterwards, I'm suggesting
the following patch to fix the bug.
--- display.c.redisplay 2007-11-28 17:16:50.000000000 +0100
+++ display.c 2007-11-29 13:42:18.000000000 +0100
@@ -1038,23 +1038,6 @@
position that doesn't take invisible characters in the prompt
into account. We use a fudge factor to compensate. */
- /* Since _rl_backspace() doesn't know about invisible characters in
the
- prompt, and there's no good way to tell it, we compensate for
- those characters here and call _rl_backspace() directly. */
- if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
- {
- /* TX == new physical cursor position in multibyte locale. */
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
- tx = _rl_col_width (&visible_line[pos], 0, nleft) -
visible_wrap_offset;
- else
- tx = nleft;
- if (_rl_last_c_pos > tx)
- {
- _rl_backspace (_rl_last_c_pos - tx); /* XXX */
- _rl_last_c_pos = tx;
- }
- }
-
/* We need to note that in a multibyte locale we are dealing with
_rl_last_c_pos as an absolute cursor position, but moving to a
point specified by a buffer position (NLEFT) that doesn't take
--
Miroslav Lichvar
- [Bug-readline] [PATCH] fix cursor position after completion,
Miroslav Lichvar <=