Skip to content

Commit

Permalink
Add user preference "HistoryBackwardSearchUntilChanged"
Browse files Browse the repository at this point in the history
When executing the same command multiple times, it is stored in history
multiple times and also appears multiple times when doing a backward search
in the history. Setting this option to <K>true</K> ensures that during a
backward search a history item is selected which actually changes the
currently displayed line. Note: This does not affect forward searches.
  • Loading branch information
zickgraf committed Mar 13, 2023
1 parent 361953a commit 696a908
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/cmdledit.g
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ readline support.",
default := "default",
) );

DeclareUserPreference( rec(
name:= "HistoryBackwardSearchUntilChanged",
description:= [
"When executing the same command multiple times, it is stored in history \
multiple times and also appears multiple times when doing a backward search \
in the history. Setting this option to <K>true</K> ensures that during a \
backward search a history item is selected which actually changes the \
currently displayed line. Note: This does not affect forward searches."
],
default:= false,
values:= [ true, false ],
multi:= false,
) );


if GAPInfo.CommandLineOptions.E then
############################################################################
Expand Down Expand Up @@ -543,6 +557,9 @@ GAPInfo.CommandLineEditFunctions.Functions.BackwardHistory := function(l)
while n > 1 do
n := n - 1;
if PositionSublist(hist[n], start) = 1 then
if UserPreference("HistoryBackwardSearchUntilChanged") and hist[n] = l[3] then
continue;
fi;
GAPInfo.History.Pos := n;
GAPInfo.History.Last := n;
return [1, Length(l[3])+1, hist[n], l[4]];
Expand Down

0 comments on commit 696a908

Please sign in to comment.