if the search fails, clear selection and try again

This really smells like we're working around a vte bug/limitation.
Thanks to @numerical.

This closes #76
This commit is contained in:
Simon Gomizelj 2013-04-11 21:05:06 -04:00
parent 05eb389c48
commit 56ac2acf44
1 changed files with 15 additions and 4 deletions

View File

@ -922,16 +922,27 @@ GtkTreeModel *create_completion_model(VteTerminal *vte) {
} }
void search(VteTerminal *vte, const char *pattern, bool reverse) { void search(VteTerminal *vte, const char *pattern, bool reverse) {
std::function<int ()> terminal_search;
if (!reverse) {
terminal_search = [vte]() {
return vte_terminal_search_find_next(vte);
};
} else {
terminal_search = [vte]() {
return vte_terminal_search_find_previous(vte);
};
};
GRegex *regex = vte_terminal_search_get_gregex(vte); GRegex *regex = vte_terminal_search_get_gregex(vte);
if (regex) g_regex_unref(regex); if (regex) g_regex_unref(regex);
regex = g_regex_new(pattern, (GRegexCompileFlags)0, (GRegexMatchFlags)0, nullptr); regex = g_regex_new(pattern, (GRegexCompileFlags)0, (GRegexMatchFlags)0, nullptr);
vte_terminal_search_set_gregex(vte, regex); vte_terminal_search_set_gregex(vte, regex);
if (!reverse) { if (!terminal_search()) {
vte_terminal_search_find_next(vte); vte_terminal_select_none(vte);
} else { terminal_search();
vte_terminal_search_find_previous(vte);
} }
vte_terminal_copy_primary(vte); vte_terminal_copy_primary(vte);
} }