diff --git a/src/document.h b/src/document.h index 201f0a5d..e22fbf88 100755 --- a/src/document.h +++ b/src/document.h @@ -1175,12 +1175,11 @@ struct Document { return nullptr; } - case A_SEARCHNEXT: { - return SearchNext(dc, false, true, false); - } - + case A_SEARCHNEXT: case A_SEARCHPREV: { - return SearchNext(dc, false, true, true); + return (sys->searchstring.Len()) ? + SearchNext(dc, false, true, k == A_SEARCHPREV) : + LoadSearch(); } case A_CASESENSITIVESEARCH: { @@ -2024,10 +2023,20 @@ struct Document { } } + const wxChar *LoadSearch() { + if (Cell *c = selected.ThinExpand(this)) { + sys->frame->filter->SetValue(c->text.t); + sys->frame->filter->SetFocus(); + return _(L"Search string was loaded from selection."); + } else { + return _(L"You need to select one cell if you want to search for its text."); + } + } + const wxChar *SearchNext(wxDC &dc, bool focusmatch, bool jump, bool reverse) { + if (!rootgrid) return nullptr; //fix crash when opening new doc if (!sys->searchstring.Len()) return _(L"No search string."); bool lastsel = true; - if (!rootgrid) return nullptr; //fix crash when opening new doc Cell *next = rootgrid->FindNextSearchMatch(sys->searchstring, nullptr, selected.GetCell(), lastsel, reverse); sys->frame->SetSearchTextBoxBackgroundColour(next);