Skip to content

Commit

Permalink
support prompt history in isearch
Browse files Browse the repository at this point in the history
previously, exiting the isearch prompt would `_cancel` which discards
prompt contents. swapping this for `_submit` causes prompt history to
be saved similar to other prompts.

since `up` and `down` already control moving between matches, use
`C-n` and `C-p` (similar to readline) for navigating prompt history.
  • Loading branch information
adsr committed Sep 11, 2024
1 parent 82450ca commit 58f29e4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 7 additions & 5 deletions editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1984,11 +1984,13 @@ static void _editor_init_kmaps(editor_t *editor) {
MLE_KBINDING_DEF("_editor_prompt_isearch_viewport_up", "pgup"),
MLE_KBINDING_DEF("_editor_prompt_isearch_viewport_down", "pgdn"),
MLE_KBINDING_DEF("_editor_prompt_isearch_drop_cursors", "C-/"),
MLE_KBINDING_DEF("_editor_prompt_cancel", "enter"),
MLE_KBINDING_DEF("_editor_prompt_cancel", "M-enter"),
MLE_KBINDING_DEF("_editor_prompt_cancel", "C-c"),
MLE_KBINDING_DEF("_editor_prompt_cancel", "C-x"),
MLE_KBINDING_DEF("_editor_prompt_cancel", "M-c"),
MLE_KBINDING_DEF("_editor_prompt_input_submit", "enter"),
MLE_KBINDING_DEF("_editor_prompt_input_submit", "M-enter"),
MLE_KBINDING_DEF("_editor_prompt_input_submit", "C-c"),
MLE_KBINDING_DEF("_editor_prompt_input_submit", "C-x"),
MLE_KBINDING_DEF("_editor_prompt_input_submit", "M-c"),
MLE_KBINDING_DEF("_editor_prompt_history_up", "C-p"),
MLE_KBINDING_DEF("_editor_prompt_history_down", "C-n"),
MLE_KBINDING_DEF(NULL, NULL)
});
}
Expand Down
9 changes: 8 additions & 1 deletion tests/func/test_search_replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,20 @@ expected[rfind_cursor_line]='^bview.0.cursor.0.mark.line_index=1$'
expected[rfind_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
source 'test.sh'

# cmd_isearch
# cmd_isearch 1
macro='a c t o r enter a p p l e enter a p p e t i t e enter a z u r e M-\ C-r a p p e enter'
declare -A expected
expected[isearch_cursor_line]='^bview.0.cursor.0.mark.line_index=2$'
expected[iesarch_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
source 'test.sh'

# cmd_isearch 2
macro='i enter a enter b enter a enter b M-\ C-r a enter C-r b enter C-r C-n C-n'
declare -A expected
expected[isearch_cursor_line]='^bview.0.cursor.0.mark.line_index=3$'
expected[iesarch_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
source 'test.sh'

# cmd_replace 1
macro='a 1 space b 2 space c 3 space d 4 C-t \ d + enter x enter y n a'
declare -A expected
Expand Down

0 comments on commit 58f29e4

Please sign in to comment.