[erlang-bugs] Silly eshell history behavior
Matthew Dempsky
matthew@REDACTED
Thu Mar 27 19:38:09 CET 2008
Run erl, type "1.", hit enter, type "2.", hit enter, press up, press
down, press up.
I expect at the end of this sequence for the command edit buffer to
contain "2.", not "1.". Below is a patch for this.
Let me know if this breaks any intentional behavior and I will revise
it as necessary.
--- lib/kernel/src/group.erl 2008-03-27 11:34:12.000000000 -0700
+++ lib/kernel/src/group.erl.orig 2007-11-26 10:55:37.000000000 -0800
@@ -329,9 +329,9 @@ get_line1({undefined,{_A,Mode,Char},Cs,C
or ((Mode =:= meta_left_sq_bracket) and (Char =:= $A)) ->
send_drv_reqs(Drv, Rs),
case up_stack(Ls0) of
- {none,_Ls} ->
+ {none,Ls} ->
send_drv(Drv, beep),
- get_line1(edlin:edit_line(Cs, Cont), Drv, Ls0);
+ get_line1(edlin:edit_line(Cs, Cont), Drv, Ls);
{Lcs,Ls} ->
send_drv_reqs(Drv, edlin:erase_line(Cont)),
{more_chars,Ncont,Nrs} = edlin:start(edlin:prompt(Cont)),
@@ -346,9 +346,9 @@ get_line1({undefined,{_A,Mode,Char},_Cs,
or ((Mode =:= meta_left_sq_bracket) and (Char =:= $B)) ->
send_drv_reqs(Drv, Rs),
case down_stack(Ls0) of
- {none,Ls} ->
+ {none,_Ls} ->
send_drv_reqs(Drv, edlin:erase_line(Cont)),
- get_line1(edlin:start(edlin:prompt(Cont)), Drv, Ls);
+ get_line1(edlin:start(edlin:prompt(Cont)), Drv, Ls0);
{Lcs,Ls} ->
send_drv_reqs(Drv, edlin:erase_line(Cont)),
{more_chars,Ncont,Nrs} = edlin:start(edlin:prompt(Cont)),
@@ -407,17 +407,21 @@ new_stack(Ls) -> {stack,Ls,{},[]}.
up_stack({stack,[L|U],{},D}) ->
{L,{stack,U,L,D}};
+up_stack({stack,[L|U],C,D}) ->
+ {L,{stack,U,L,[C|D]}};
up_stack({stack,[],{},D}) ->
{none,{stack,[],{},D}};
-up_stack({stack,U,C,D}) ->
- up_stack({stack,U,{},[C|D]}).
+up_stack({stack,[],C,D}) ->
+ {none,{stack,[C],{},D}}.
down_stack({stack,U,{},[L|D]}) ->
{L,{stack,U,L,D}};
+down_stack({stack,U,C,[L|D]}) ->
+ {L,{stack,[C|U],L,D}};
down_stack({stack,U,{},[]}) ->
{none,{stack,U,{},[]}};
-down_stack({stack,U,C,D}) ->
- down_stack({stack,[C|U],{},D}).
+down_stack({stack,U,C,[]}) ->
+ {none,{stack,U,{},[C]}}.
%% This is get_line without line editing (except for backspace) and
%% without echo.
More information about the erlang-bugs
mailing list