about summary refs log tree commit diff stats
path: root/text_tests.lua
diff options
context:
space:
mode:
Diffstat (limited to 'text_tests.lua')
-rw-r--r--text_tests.lua152
1 files changed, 76 insertions, 76 deletions
diff --git a/text_tests.lua b/text_tests.lua
index bedd73d..b45c4f0 100644
--- a/text_tests.lua
+++ b/text_tests.lua
@@ -24,7 +24,7 @@ function test_backspace_from_start_of_final_line()
   Editor_state.cursor1 = {line=2, pos=1}
   Text.redraw_all(Editor_state)
   -- backspace scrolls up
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(#Editor_state.lines, 1, '#lines')
   check_eq(Editor_state.cursor1.line, 1, 'cursor')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
@@ -50,7 +50,7 @@ function test_press_ctrl()
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
-  edit.run_after_keychord(Editor_state, 'C-m')
+  edit.run_after_keychord(Editor_state, 'C-m', 'm')
 end
 
 function test_move_left()
@@ -60,7 +60,7 @@ function test_move_left()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=2}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'left')
+  edit.run_after_keychord(Editor_state, 'left', 'left')
   check_eq(Editor_state.cursor1.pos, 1, 'check')
 end
 
@@ -71,7 +71,7 @@ function test_move_right()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=1}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'right')
+  edit.run_after_keychord(Editor_state, 'right', 'right')
   check_eq(Editor_state.cursor1.pos, 2, 'check')
 end
 
@@ -82,7 +82,7 @@ function test_move_left_to_previous_line()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=2, pos=1}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'left')
+  edit.run_after_keychord(Editor_state, 'left', 'left')
   check_eq(Editor_state.cursor1.line, 1, 'line')
   check_eq(Editor_state.cursor1.pos, 4, 'pos')  -- past end of line
 end
@@ -94,7 +94,7 @@ function test_move_right_to_next_line()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=4}  -- past end of line
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'right')
+  edit.run_after_keychord(Editor_state, 'right', 'right')
   check_eq(Editor_state.cursor1.line, 2, 'line')
   check_eq(Editor_state.cursor1.pos, 1, 'pos')
 end
@@ -106,7 +106,7 @@ function test_move_to_start_of_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=3}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.pos, 1, 'check')
 end
 
@@ -117,7 +117,7 @@ function test_move_to_start_of_previous_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=4}  -- at the space between words
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.pos, 1, 'check')
 end
 
@@ -128,7 +128,7 @@ function test_skip_to_previous_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=5}  -- at the start of second word
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.pos, 1, 'check')
 end
 
@@ -139,7 +139,7 @@ function test_skip_past_tab_to_previous_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=10}  -- within third word
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.pos, 9, 'check')
 end
 
@@ -150,7 +150,7 @@ function test_skip_multiple_spaces_to_previous_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=6}  -- at the start of second word
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.pos, 1, 'check')
 end
 
@@ -161,7 +161,7 @@ function test_move_to_start_of_word_on_previous_line()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=2, pos=1}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-left')
+  edit.run_after_keychord(Editor_state, 'M-left', 'left')
   check_eq(Editor_state.cursor1.line, 1, 'line')
   check_eq(Editor_state.cursor1.pos, 5, 'pos')
 end
@@ -173,7 +173,7 @@ function test_move_past_end_of_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=1}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-right')
+  edit.run_after_keychord(Editor_state, 'M-right', 'right')
   check_eq(Editor_state.cursor1.pos, 4, 'check')
 end
 
@@ -184,7 +184,7 @@ function test_skip_to_next_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=4}  -- at the space between words
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-right')
+  edit.run_after_keychord(Editor_state, 'M-right', 'right')
   check_eq(Editor_state.cursor1.pos, 8, 'check')
 end
 
@@ -195,7 +195,7 @@ function test_skip_past_tab_to_next_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=1}  -- at the space between words
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-right')
+  edit.run_after_keychord(Editor_state, 'M-right', 'right')
   check_eq(Editor_state.cursor1.pos, 4, 'check')
 end
 
@@ -206,7 +206,7 @@ function test_skip_multiple_spaces_to_next_word()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=4}  -- at the start of second word
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-right')
+  edit.run_after_keychord(Editor_state, 'M-right', 'right')
   check_eq(Editor_state.cursor1.pos, 9, 'check')
 end
 
@@ -217,7 +217,7 @@ function test_move_past_end_of_word_on_next_line()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=1, pos=8}
   edit.draw(Editor_state)
-  edit.run_after_keychord(Editor_state, 'M-right')
+  edit.run_after_keychord(Editor_state, 'M-right', 'right')
   check_eq(Editor_state.cursor1.line, 2, 'line')
   check_eq(Editor_state.cursor1.pos, 4, 'pos')
 end
@@ -566,7 +566,7 @@ function test_select_text()
   edit.draw(Editor_state)
   -- select a letter
   App.fake_key_press('lshift')
-  edit.run_after_keychord(Editor_state, 'S-right')
+  edit.run_after_keychord(Editor_state, 'S-right', 'right')
   App.fake_key_release('lshift')
   edit.key_release(Editor_state, 'lshift')
   -- selection persists even after shift is released
@@ -588,7 +588,7 @@ function test_cursor_movement_without_shift_resets_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- press an arrow key without shift
-  edit.run_after_keychord(Editor_state, 'right')
+  edit.run_after_keychord(Editor_state, 'right', 'right')
   -- no change to data, selection is reset
   check_nil(Editor_state.selection1.line, 'check')
   check_eq(Editor_state.lines[1].data, 'abc', 'data')
@@ -645,7 +645,7 @@ function test_copy_does_not_reset_selection()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- copy selection
-  edit.run_after_keychord(Editor_state, 'C-c')
+  edit.run_after_keychord(Editor_state, 'C-c', 'c')
   check_eq(App.clipboard, 'a', 'clipboard')
   -- selection is reset since shift key is not pressed
   check(Editor_state.selection1.line, 'check')
@@ -663,7 +663,7 @@ function test_cut()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- press a key
-  edit.run_after_keychord(Editor_state, 'C-x')
+  edit.run_after_keychord(Editor_state, 'C-x', 'x')
   check_eq(App.clipboard, 'a', 'clipboard')
   -- selected text is deleted
   check_eq(Editor_state.lines[1].data, 'bc', 'data')
@@ -683,7 +683,7 @@ function test_paste_replaces_selection()
   -- set clipboard
   App.clipboard = 'xyz'
   -- paste selection
-  edit.run_after_keychord(Editor_state, 'C-v')
+  edit.run_after_keychord(Editor_state, 'C-v', 'v')
   -- selection is reset since shift key is not pressed
   -- selection includes the newline, so it's also deleted
   check_eq(Editor_state.lines[1].data, 'xyzdef', 'check')
@@ -708,7 +708,7 @@ function test_deleting_selection_may_scroll()
   -- set up a selection starting above the currently displayed page
   Editor_state.selection1 = {line=1, pos=2}
   -- delete selection
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   -- page scrolls up
   check_eq(Editor_state.screen_top1.line, 1, 'check')
   check_eq(Editor_state.lines[1].data, 'ahi', 'data')
@@ -749,7 +749,7 @@ function test_insert_newline()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- hitting the enter key splits the line
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
@@ -771,7 +771,7 @@ function test_insert_newline_at_start_of_line()
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   -- hitting the enter key splits the line
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
   check_eq(Editor_state.lines[1].data, '', 'data:1')
@@ -796,7 +796,7 @@ function test_insert_from_clipboard()
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- paste some text including a newline, check that new line is created
   App.clipboard = 'xy\nz'
-  edit.run_after_keychord(Editor_state, 'C-v')
+  edit.run_after_keychord(Editor_state, 'C-v', 'v')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, 'cursor:pos')
@@ -956,7 +956,7 @@ function test_select_all_text()
   edit.draw(Editor_state)
   -- select all
   App.fake_key_press('lctrl')
-  edit.run_after_keychord(Editor_state, 'C-a')
+  edit.run_after_keychord(Editor_state, 'C-a', 'a')
   App.fake_key_release('lctrl')
   edit.key_release(Editor_state, 'lctrl')
   -- selection
@@ -978,7 +978,7 @@ function test_cut_without_selection()
   Editor_state.selection1 = {}
   edit.draw(Editor_state)
   -- try to cut without selecting text
-  edit.run_after_keychord(Editor_state, 'C-x')
+  edit.run_after_keychord(Editor_state, 'C-x', 'x')
   -- no crash
   check_nil(Editor_state.selection1.line, 'check')
 end
@@ -998,7 +998,7 @@ function test_pagedown()
   y = y + Editor_state.line_height
   App.screen.check(y, 'def', 'baseline/screen:2')
   -- after pagedown the bottom line becomes the top
-  edit.run_after_keychord(Editor_state, 'pagedown')
+  edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'cursor')
   y = Editor_state.top
@@ -1024,7 +1024,7 @@ function test_pagedown_often_shows_start_of_wrapping_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi ', 'baseline/screen:3')
   -- after pagedown we start drawing from the bottom _line_ (multiple screen lines)
-  edit.run_after_keychord(Editor_state, 'pagedown')
+  edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top:line')
   check_eq(Editor_state.screen_top1.pos, 1, 'screen_top:pos')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
@@ -1054,7 +1054,7 @@ function test_pagedown_can_start_from_middle_of_long_wrapping_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi ', 'baseline/screen:3')
   -- after pagedown we scroll down the very long wrapping line
-  edit.run_after_keychord(Editor_state, 'pagedown')
+  edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line')
   check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos')
   y = Editor_state.top
@@ -1083,7 +1083,7 @@ function test_pagedown_never_moves_up()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- pagedown makes no change
-  edit.run_after_keychord(Editor_state, 'pagedown')
+  edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top:line')
   check_eq(Editor_state.screen_top1.pos, 9, 'screen_top:pos')
 end
@@ -1105,7 +1105,7 @@ function test_down_arrow_moves_cursor()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- after hitting the down arrow, the cursor moves down by 1 line
-  edit.run_after_keychord(Editor_state, 'down')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'cursor')
   -- the screen is unchanged
@@ -1134,7 +1134,7 @@ function test_down_arrow_scrolls_down_by_one_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- after hitting the down arrow the screen scrolls down by one line
-  edit.run_after_keychord(Editor_state, 'down')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 4, 'cursor')
   y = Editor_state.top
@@ -1162,7 +1162,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi ', 'baseline/screen:3')  -- line wrapping includes trailing whitespace
   -- after hitting the down arrow the screen scrolls down by one line
-  edit.run_after_keychord(Editor_state, 'down')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos')
@@ -1191,7 +1191,7 @@ function test_down_arrow_scrolls_down_by_one_screen_line_after_splitting_within_
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghij', 'baseline/screen:3')
   -- after hitting the down arrow the screen scrolls down by one line
-  edit.run_after_keychord(Editor_state, 'down')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos')
@@ -1219,12 +1219,12 @@ function test_pagedown_followed_by_down_arrow_does_not_scroll_screen_up()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghij', 'baseline/screen:3')
   -- after hitting pagedown the screen scrolls down to start of a long line
-  edit.run_after_keychord(Editor_state, 'pagedown')
+  edit.run_after_keychord(Editor_state, 'pagedown', 'pagedown')
   check_eq(Editor_state.screen_top1.line, 3, 'baseline2/screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'baseline2/cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'baseline2/cursor:pos')
   -- after hitting down arrow the screen doesn't scroll down further, and certainly doesn't scroll up
-  edit.run_after_keychord(Editor_state, 'down')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
   check_eq(Editor_state.screen_top1.line, 3, 'screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos')
@@ -1253,7 +1253,7 @@ function test_up_arrow_moves_cursor()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- after hitting the up arrow the cursor moves up by 1 line
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 2, 'cursor')
   -- the screen is unchanged
@@ -1282,7 +1282,7 @@ function test_up_arrow_scrolls_up_by_one_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'jkl', 'baseline/screen:3')
   -- after hitting the up arrow the screen scrolls up by one line
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor')
   y = Editor_state.top
@@ -1308,7 +1308,7 @@ function test_up_arrow_scrolls_up_by_one_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:2')
   -- after hitting the up arrow the screen scrolls up to first screen line
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   y = Editor_state.top
   App.screen.check(y, 'ghi ', 'screen:1')
   y = y + Editor_state.line_height
@@ -1338,7 +1338,7 @@ function test_up_arrow_scrolls_up_to_final_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:3')
   -- after hitting the up arrow the screen scrolls up to final screen line of previous line
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   y = Editor_state.top
   App.screen.check(y, 'def', 'screen:1')
   y = y + Editor_state.line_height
@@ -1368,7 +1368,7 @@ function test_up_arrow_scrolls_up_to_empty_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- after hitting the up arrow the screen scrolls up by one line
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor')
   y = Editor_state.top
@@ -1394,7 +1394,7 @@ function test_pageup()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:2')
   -- after pageup the cursor goes to first line
-  edit.run_after_keychord(Editor_state, 'pageup')
+  edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor')
   y = Editor_state.top
@@ -1420,7 +1420,7 @@ function test_pageup_scrolls_up_by_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:3')  -- line wrapping includes trailing whitespace
   -- after hitting the page-up key the screen scrolls up to top
-  edit.run_after_keychord(Editor_state, 'pageup')
+  edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
@@ -1447,7 +1447,7 @@ function test_pageup_scrolls_up_from_middle_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:3')  -- line wrapping includes trailing whitespace
   -- after hitting the page-up key the screen scrolls up to top
-  edit.run_after_keychord(Editor_state, 'pageup')
+  edit.run_after_keychord(Editor_state, 'pageup', 'pageup')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
@@ -1476,7 +1476,7 @@ function test_enter_on_bottom_line_scrolls_down()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi', 'baseline/screen:3')
   -- after hitting the enter key the screen scrolls down
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 4, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
@@ -1501,7 +1501,7 @@ function test_enter_on_final_line_avoids_scrolling_down_when_not_at_bottom()
   local y = Editor_state.top
   App.screen.check(y, 'jkl', 'baseline/screen:1')
   -- after hitting the enter key the screen does not scroll down
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.screen_top1.line, 4, 'screen_top')
   check_eq(Editor_state.cursor1.line, 5, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, 'cursor:pos')
@@ -1577,7 +1577,7 @@ function test_left_arrow_scrolls_up_in_wrapped_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:2')
   -- after hitting the left arrow the screen scrolls up to first screen line
-  edit.run_after_keychord(Editor_state, 'left')
+  edit.run_after_keychord(Editor_state, 'left', 'left')
   y = Editor_state.top
   App.screen.check(y, 'ghi ', 'screen:1')
   y = y + Editor_state.line_height
@@ -1608,7 +1608,7 @@ function test_right_arrow_scrolls_down_in_wrapped_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi ', 'baseline/screen:3')  -- line wrapping includes trailing whitespace
   -- after hitting the right arrow the screen scrolls down by one line
-  edit.run_after_keychord(Editor_state, 'right')
+  edit.run_after_keychord(Editor_state, 'right', 'right')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 6, 'cursor:pos')
@@ -1636,7 +1636,7 @@ function test_home_scrolls_up_in_wrapped_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:2')
   -- after hitting home the screen scrolls up to first screen line
-  edit.run_after_keychord(Editor_state, 'home')
+  edit.run_after_keychord(Editor_state, 'home', 'home')
   y = Editor_state.top
   App.screen.check(y, 'ghi ', 'screen:1')
   y = y + Editor_state.line_height
@@ -1667,7 +1667,7 @@ function test_end_scrolls_down_in_wrapped_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'ghi ', 'baseline/screen:3')  -- line wrapping includes trailing whitespace
   -- after hitting end the screen scrolls down by one line
-  edit.run_after_keychord(Editor_state, 'end')
+  edit.run_after_keychord(Editor_state, 'end', 'end')
   check_eq(Editor_state.screen_top1.line, 2, 'screen_top')
   check_eq(Editor_state.cursor1.line, 3, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 8, 'cursor:pos')
@@ -1730,7 +1730,7 @@ function test_backspace_can_scroll_up()
   y = y + Editor_state.line_height
   App.screen.check(y, 'jkl', 'baseline/screen:3')
   -- after hitting backspace the screen scrolls up by one line
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.screen_top1.line, 1, 'screen_top')
   check_eq(Editor_state.cursor1.line, 1, 'cursor')
   y = Editor_state.top
@@ -1756,7 +1756,7 @@ function test_backspace_can_scroll_up_screen_line()
   y = y + Editor_state.line_height
   App.screen.check(y, 'mno', 'baseline/screen:2')
   -- after hitting backspace the screen scrolls up by one screen line
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   y = Editor_state.top
   App.screen.check(y, 'ghij', 'screen:1')
   y = y + Editor_state.line_height
@@ -1777,7 +1777,7 @@ function test_backspace_past_line_boundary()
   Text.redraw_all(Editor_state)
   Editor_state.cursor1 = {line=2, pos=1}
   -- backspace joins with previous line
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'abcdef', 'check')
 end
 
@@ -1793,7 +1793,7 @@ function test_backspace_over_selection()
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.selection1 = {line=1, pos=2}
   -- backspace deletes the selected character, even though it's after the cursor
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'bc', 'data')
   -- cursor (remains) at start of selection
   check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
@@ -1811,7 +1811,7 @@ function test_backspace_over_selection_reverse()
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=1, pos=1}
   -- backspace deletes the selected character
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'bc', 'data')
   -- cursor moves to start of selection
   check_eq(Editor_state.cursor1.line, 1, 'cursor:line')
@@ -1829,7 +1829,7 @@ function test_backspace_over_multiple_lines()
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=4, pos=2}
   -- backspace deletes the region and joins the remaining portions of lines on either side
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'akl', 'data:1')
   check_eq(Editor_state.lines[2].data, 'mno', 'data:2')
   -- cursor remains at start of selection
@@ -1848,7 +1848,7 @@ function test_backspace_to_end_of_line()
   Editor_state.cursor1 = {line=1, pos=2}
   Editor_state.selection1 = {line=1, pos=4}
   -- backspace deletes rest of line without joining to any other line
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'a', 'data:1')
   check_eq(Editor_state.lines[2].data, 'def', 'data:2')
   -- cursor remains at start of selection
@@ -1867,7 +1867,7 @@ function test_backspace_to_start_of_line()
   Editor_state.cursor1 = {line=2, pos=1}
   Editor_state.selection1 = {line=2, pos=3}
   -- backspace deletes beginning of line without joining to any other line
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.lines[1].data, 'abc', 'data:1')
   check_eq(Editor_state.lines[2].data, 'f', 'data:2')
   -- cursor remains at start of selection
@@ -1899,7 +1899,7 @@ function test_undo_insert_text()
   y = y + Editor_state.line_height
   App.screen.check(y, 'xyz', 'baseline/screen:3')
   -- undo
-  edit.run_after_keychord(Editor_state, 'C-z')
+  edit.run_after_keychord(Editor_state, 'C-z', 'z')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 4, 'cursor:pos')
   check_nil(Editor_state.selection1.line, 'selection:line')
@@ -1921,7 +1921,7 @@ function test_undo_delete_text()
   Editor_state.screen_top1 = {line=1, pos=1}
   Editor_state.screen_bottom1 = {}
   -- delete a character
-  edit.run_after_keychord(Editor_state, 'backspace')
+  edit.run_after_keychord(Editor_state, 'backspace', 'backspace')
   check_eq(Editor_state.cursor1.line, 2, 'baseline/cursor:line')
   check_eq(Editor_state.cursor1.pos, 4, 'baseline/cursor:pos')
   check_nil(Editor_state.selection1.line, 'baseline/selection:line')
@@ -1934,7 +1934,7 @@ function test_undo_delete_text()
   App.screen.check(y, 'xyz', 'baseline/screen:3')
   -- undo
 --?   -- after undo, the backspaced key is selected
-  edit.run_after_keychord(Editor_state, 'C-z')
+  edit.run_after_keychord(Editor_state, 'C-z', 'z')
   check_eq(Editor_state.cursor1.line, 2, 'cursor:line')
   check_eq(Editor_state.cursor1.pos, 5, 'cursor:pos')
   check_nil(Editor_state.selection1.line, 'selection:line')
@@ -1965,8 +1965,8 @@ function test_undo_restores_selection()
   check_eq(Editor_state.lines[1].data, 'xbc', 'baseline')
   check_nil(Editor_state.selection1.line, 'baseline:selection')
   -- undo
-  edit.run_after_keychord(Editor_state, 'C-z')
-  edit.run_after_keychord(Editor_state, 'C-z')
+  edit.run_after_keychord(Editor_state, 'C-z', 'z')
+  edit.run_after_keychord(Editor_state, 'C-z', 'z')
   -- selection is restored
   check_eq(Editor_state.selection1.line, 1, 'line')
   check_eq(Editor_state.selection1.pos, 2, 'pos')
@@ -1982,19 +1982,19 @@ function test_search()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- search for a string
-  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_keychord(Editor_state, 'C-f', 'f')
   edit.run_after_text_input(Editor_state, 'd')
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.cursor1.line, 2, '1/cursor:line')
   check_eq(Editor_state.cursor1.pos, 1, '1/cursor:pos')
   -- reset cursor
   Editor_state.cursor1 = {line=1, pos=1}
   Editor_state.screen_top1 = {line=1, pos=1}
   -- search for second occurrence
-  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_keychord(Editor_state, 'C-f', 'f')
   edit.run_after_text_input(Editor_state, 'de')
-  edit.run_after_keychord(Editor_state, 'down')
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'down', 'down')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   check_eq(Editor_state.cursor1.line, 4, '2/cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos')
 end
@@ -2009,10 +2009,10 @@ function test_search_upwards()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- search for a string
-  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_keychord(Editor_state, 'C-f', 'f')
   edit.run_after_text_input(Editor_state, 'a')
   -- search for previous occurrence
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   check_eq(Editor_state.cursor1.line, 1, '2/cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, '2/cursor:pos')
 end
@@ -2027,9 +2027,9 @@ function test_search_wrap()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- search for a string
-  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_keychord(Editor_state, 'C-f', 'f')
   edit.run_after_text_input(Editor_state, 'a')
-  edit.run_after_keychord(Editor_state, 'return')
+  edit.run_after_keychord(Editor_state, 'return', 'return')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, '1/cursor:line')
   check_eq(Editor_state.cursor1.pos, 2, '1/cursor:pos')
@@ -2045,9 +2045,9 @@ function test_search_wrap_upwards()
   Editor_state.screen_bottom1 = {}
   edit.draw(Editor_state)
   -- search upwards for a string
-  edit.run_after_keychord(Editor_state, 'C-f')
+  edit.run_after_keychord(Editor_state, 'C-f', 'f')
   edit.run_after_text_input(Editor_state, 'a')
-  edit.run_after_keychord(Editor_state, 'up')
+  edit.run_after_keychord(Editor_state, 'up', 'up')
   -- cursor wraps
   check_eq(Editor_state.cursor1.line, 1, '1/cursor:line')
   check_eq(Editor_state.cursor1.pos, 6, '1/cursor:pos')