Skip to content

Commit 58f29e4

Browse files
committed
support prompt history in isearch
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.
1 parent 82450ca commit 58f29e4

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

editor.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,11 +1984,13 @@ static void _editor_init_kmaps(editor_t *editor) {
19841984
MLE_KBINDING_DEF("_editor_prompt_isearch_viewport_up", "pgup"),
19851985
MLE_KBINDING_DEF("_editor_prompt_isearch_viewport_down", "pgdn"),
19861986
MLE_KBINDING_DEF("_editor_prompt_isearch_drop_cursors", "C-/"),
1987-
MLE_KBINDING_DEF("_editor_prompt_cancel", "enter"),
1988-
MLE_KBINDING_DEF("_editor_prompt_cancel", "M-enter"),
1989-
MLE_KBINDING_DEF("_editor_prompt_cancel", "C-c"),
1990-
MLE_KBINDING_DEF("_editor_prompt_cancel", "C-x"),
1991-
MLE_KBINDING_DEF("_editor_prompt_cancel", "M-c"),
1987+
MLE_KBINDING_DEF("_editor_prompt_input_submit", "enter"),
1988+
MLE_KBINDING_DEF("_editor_prompt_input_submit", "M-enter"),
1989+
MLE_KBINDING_DEF("_editor_prompt_input_submit", "C-c"),
1990+
MLE_KBINDING_DEF("_editor_prompt_input_submit", "C-x"),
1991+
MLE_KBINDING_DEF("_editor_prompt_input_submit", "M-c"),
1992+
MLE_KBINDING_DEF("_editor_prompt_history_up", "C-p"),
1993+
MLE_KBINDING_DEF("_editor_prompt_history_down", "C-n"),
19921994
MLE_KBINDING_DEF(NULL, NULL)
19931995
});
19941996
}

tests/func/test_search_replace.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,20 @@ expected[rfind_cursor_line]='^bview.0.cursor.0.mark.line_index=1$'
5656
expected[rfind_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
5757
source 'test.sh'
5858

59-
# cmd_isearch
59+
# cmd_isearch 1
6060
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'
6161
declare -A expected
6262
expected[isearch_cursor_line]='^bview.0.cursor.0.mark.line_index=2$'
6363
expected[iesarch_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
6464
source 'test.sh'
6565

66+
# cmd_isearch 2
67+
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'
68+
declare -A expected
69+
expected[isearch_cursor_line]='^bview.0.cursor.0.mark.line_index=3$'
70+
expected[iesarch_cursor_col ]='^bview.0.cursor.0.mark.col=0$'
71+
source 'test.sh'
72+
6673
# cmd_replace 1
6774
macro='a 1 space b 2 space c 3 space d 4 C-t \ d + enter x enter y n a'
6875
declare -A expected

0 commit comments

Comments
 (0)