History

console.lua: don't duplicate the check to add to history

Guido Cella committed 1 year ago

Commit 6f2ce8a1 parent 0b3cc3a1 file · +6 −4Browse files

Unified · Split

player/lua/console.lua+6−4
@@ -873,6 +873,10 @@ end · 872 unmodified lines
873873
874874 -- Add a line to the history and deduplicate
875875 local function history_add(text)
876+ if history[#history] == text or text == '' then
877+ return
878+ end
879+
876880 if opts.history_dedup then
877881 -- More recent entries are more likely to be repeated
878882 for i = #history, 1, -1 do
@@ -1028,9 +1032,7 @@ local function submit() · 149 unmodified lines
10281032 mp.commandv('script-message-to', input_caller, 'input-event', 'submit',
10291033 utils.format_json({line}))
10301034
1031− if history[#history] ~= line and line ~= '' then
1032− history_add(line)
1033− end
1035+ history_add(line)
10341036 end
10351037
10361038 if not keep_open then
@@ -1100,7 +1102,7 @@ local function go_history(new_pos) · 63 unmodified lines
11001102 -- If the user was editing a non-history line, save it as the last history
11011103 -- entry. This makes it much less frustrating to accidentally hit Up/Down
11021104 -- while editing a line.
1103− if old_pos == #history + 1 and line ~= '' and history[#history] ~= line then
1105+ if old_pos == #history + 1 then
11041106 history_add(line)
11051107 end
11061108

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t