bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Disable the "modify history with arrow keys" feature


From: 林自均
Subject: Re: [Bug-readline] Disable the "modify history with arrow keys" feature
Date: Sun, 3 Feb 2019 09:32:25 +0800

Hi Chet,

Thanks for the response. However, I have another opinion. I suggest the fix should be in "_rl_revert_all_lines()". The reasons are:

1. "_rl_revert_all_lines()" is a private function and only called once in "readline_internal_teardown()", so modifying it has no other side effects.
2. Since the function name "_rl_revert_all_lines()" says it's going to revert *all* lines, I think it's the comment that is incorrect and should be modified.

If you are still going with your patch, I suggest that the function name "_rl_revert_all_lines()" should be renamed. For example "_rl_revert_all_lines_before_current_history" or something like that.

Thank you.

Best,
John Lin

Chet Ramey <address@hidden> 於 2019年2月3日 週日 上午4:36寫道:
On 2/1/19 8:57 PM, 林自均 wrote:
> Hi Chet,
>
> For Frederick's problem, I suppose that is a bug. Here is my proposed patch
> (against bash code base):
>
>     diff --git a/lib/readline/misc.c b/lib/readline/misc.c
>     index 64b1457d..6aed8e64 100644
>     --- a/lib/readline/misc.c
>     +++ b/lib/readline/misc.c
>     @@ -446,7 +446,8 @@ _rl_revert_all_lines (void)
>        saved_undo_list = rl_undo_list;
>        hpos = where_history ();
>
>     -  entry = (hpos == history_length) ? previous_history () :
> current_history ();
>     +  history_set_pos (history_length);
>     +  entry = previous_history ();
>        while (entry)
>          {
>            if (ul = (UNDO_LIST *)entry->data)
>
> The root cause was that the variable "entry" should have pointed to the
> latest history entry, but it pointed to the current history instead. If I
> am missing anything, please let me know. Thanks.

This is the correct diagnosis, but I am not sure this is the right place
to fix it. The function does exactly what the comment says it should:
revert all lines before the current history entry. If the caller wants it
to act on every history line, it should ensure that the history position
is at the end before calling it (history_offset == history_length).  I'll
make the fix in readline_internal_teardown() (patch attached).

Thanks for looking at it.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]