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