Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(search): Fix getting highlights with '/e' flag #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/apitest/cmdline_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,30 @@ MU_TEST(test_insert_literal_ctrl_q)
mu_check(strcmp(vimSearchGetPattern(), "~7") == 0);
}

MU_TEST(test_search_end)
{
// Regression test for Onivim:
// https://github.com/onivim/oni2/issues/3704
vimInput("/");
vimInput("t");
vimInput("s");
vimInput("t");
vimInput("/");
vimInput("e");
mu_check(strcmp(vimSearchGetPattern(), "tst") == 0);

vimKey("<cr>");
// This was the part that failed in Onivim #3704:
mu_check(strcmp(vimSearchGetPattern(), "tst") == 0);
}

MU_TEST_SUITE(test_suite)
{
MU_SUITE_CONFIGURE(&test_setup, &test_teardown);

MU_RUN_TEST(test_cancel_inc_search);
MU_RUN_TEST(test_search_forward_esc);
MU_RUN_TEST(test_search_end);
MU_RUN_TEST(test_cancel_n);
MU_RUN_TEST(test_get_search_highlights_during_visual);
MU_RUN_TEST(test_insert_literal_ctrl_v);
Expand Down
8 changes: 4 additions & 4 deletions src/normal.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,13 +673,13 @@ executionStatus_T state_normal_cmd_execute(void *ctx, int c)
/* Seed the search - bump it forward and back so everything is set for N and n */
if (cmdc == '/')
{
(void)normal_search(&context->ca, cmdc, cmd, 0);
(void)normal_search(&context->ca, cmdc, cmd, SEARCH_REV | SEARCH_END);
(void)normal_search(&context->ca, cmdc, get_search_pat(), 0);
(void)normal_search(&context->ca, cmdc, get_search_pat(), SEARCH_REV | SEARCH_END);
}
else
{
(void)normal_search(&context->ca, cmdc, cmd, SEARCH_START);
(void)normal_search(&context->ca, cmdc, cmd, SEARCH_REV | SEARCH_START);
(void)normal_search(&context->ca, cmdc, get_search_pat(), SEARCH_START);
(void)normal_search(&context->ca, cmdc, get_search_pat(), SEARCH_REV | SEARCH_START);
}

/* TODO: SEARCH_MARK parameter - how do we wire that up? We may need to stash save_cursor somewhere. */
Expand Down