From 85b8810660ffa37eb2d3edf85a4dbf12ba5f1ca3 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+orbitalquark@users.noreply.github.com> Date: Sun, 1 Nov 2020 23:30:43 -0500 Subject: Added optional mode parameter to `ui.command_entry.append_history()`. This allows for arbitrary appending to history, not just for the current or most recent mode. --- test/test.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'test/test.lua') diff --git a/test/test.lua b/test/test.lua index cc545257..53a7cb24 100644 --- a/test/test.lua +++ b/test/test.lua @@ -1413,7 +1413,16 @@ function test_command_entry_history_append() assert_equal(ui.command_entry:get_text(), 'bar') -- no further history events.emit(events.KEYPRESS, not CURSES and 0xFF0D or 343) -- \n - assert_raises(function() ui.command_entry:append_history('text') end, 'string expected, got table') + -- Verify no previous mode or history is needed for adding history. + local f2 = function() end + ui.command_entry.append_history(f2, 'baz') + ui.command_entry.run(f2, keys) + assert_equal(ui.command_entry:get_text(), 'baz') + events.emit(events.KEYPRESS, not CURSES and 0xFF0D or 343) -- \n + + assert_raises(function() ui.command_entry.append_history(1) end, 'string expected, got number') + assert_raises(function() ui.command_entry:append_history('text') end, 'function expected, got table') + assert_raises(function() ui.command_entry.append_history(function() end, true) end, 'string/nil expected, got boolean') end function test_command_entry_mode_restore() -- cgit v1.2.3