Unified · Split
| @@ -873,6 +873,10 @@ end · 872 unmodified lines | ||
| 873 | 873 | |
| 874 | 874 | -- Add a line to the history and deduplicate |
| 875 | 875 | local function history_add(text) |
| 876 | + if history[#history] == text or text == '' then | |
| 877 | + return | |
| 878 | + end | |
| 879 | + | |
| 876 | 880 | if opts.history_dedup then |
| 877 | 881 | -- More recent entries are more likely to be repeated |
| 878 | 882 | for i = #history, 1, -1 do |
| @@ -1028,9 +1032,7 @@ local function submit() · 149 unmodified lines | ||
| 1028 | 1032 | mp.commandv('script-message-to', input_caller, 'input-event', 'submit', |
| 1029 | 1033 | utils.format_json({line})) |
| 1030 | 1034 | |
| 1031 | − if history[#history] ~= line and line ~= '' then | |
| 1032 | − history_add(line) | |
| 1033 | − end | |
| 1035 | + history_add(line) | |
| 1034 | 1036 | end |
| 1035 | 1037 | |
| 1036 | 1038 | if not keep_open then |
| @@ -1100,7 +1102,7 @@ local function go_history(new_pos) · 63 unmodified lines | ||
| 1100 | 1102 | -- If the user was editing a non-history line, save it as the last history |
| 1101 | 1103 | -- entry. This makes it much less frustrating to accidentally hit Up/Down |
| 1102 | 1104 | -- while editing a line. |
| 1103 | − if old_pos == #history + 1 and line ~= '' and history[#history] ~= line then | |
| 1105 | + if old_pos == #history + 1 then | |
| 1104 | 1106 | history_add(line) |
| 1105 | 1107 | end |
| 1106 | 1108 | |