mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 00:29:15 +00:00
Shell+LibLine: Support HISTCONTROL environment variable
This is implemented in Line::Editor meaning not only the Shell will respect it, but also js, Debugger etc. Possible values are "ignorespace", "ignoredups" and "ignoreboth", as documented in Shell-vars(7), for now. The default value for the anon user (set in .shellrc) is "ignoreboth".
This commit is contained in:
parent
4a4b1b1131
commit
d412fbdcf3
Notes:
sideshowbarker
2024-07-19 01:42:54 +09:00
Author: https://github.com/linusg
Commit: d412fbdcf3
Pull-request: https://github.com/SerenityOS/serenity/pull/3853
Reviewed-by: https://github.com/alimpfard
3 changed files with 21 additions and 1 deletions
|
@ -208,6 +208,13 @@ void Editor::add_to_history(const String& line)
|
|||
{
|
||||
if (line.is_empty())
|
||||
return;
|
||||
String histcontrol = getenv("HISTCONTROL");
|
||||
auto ignoredups = histcontrol == "ignoredups" || histcontrol == "ignoreboth";
|
||||
auto ignorespace = histcontrol == "ignorespace" || histcontrol == "ignoreboth";
|
||||
if (ignoredups && !m_history.is_empty() && line == m_history.last())
|
||||
return;
|
||||
if (ignorespace && line.starts_with(' '))
|
||||
return;
|
||||
if ((m_history.size() + 1) > m_history_capacity)
|
||||
m_history.take_first();
|
||||
m_history.append(line);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue