diff options
-rw-r--r-- | src/fe-text/textbuffer.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/fe-text/textbuffer.c b/src/fe-text/textbuffer.c index d96f080a..76f07ac8 100644 --- a/src/fe-text/textbuffer.c +++ b/src/fe-text/textbuffer.c @@ -463,7 +463,7 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline, g_return_val_if_fail(buffer != NULL, NULL); g_return_val_if_fail(text != NULL, NULL); - if (regexp && *text != '\0') { + if (regexp) { #ifdef HAVE_REGEX_H int flags = REG_EXTENDED | REG_NOSUB | (case_sensitive ? 0 : REG_ICASE); @@ -480,19 +480,21 @@ GList *textbuffer_find_text(TEXT_BUFFER_REC *buffer, LINE_REC *startline, line = startline != NULL ? startline : buffer->first_line; for (; line != NULL; line = line->next) { - if ((line->info.level & level) == 0 || - (line->info.level & nolevel) != 0) - continue; + line_matched = (line->info.level & level) != 0 && + (line->info.level & nolevel) == 0; if (*text == '\0') { /* no search word, everything matches */ - textbuffer_line_ref(line); - matches = g_list_append(matches, line); + if (line_matched) { + textbuffer_line_ref(line); + matches = g_list_append(matches, line); + } continue; } textbuffer_line2text(line, FALSE, str); + if (line_matched) line_matched = #ifdef HAVE_REGEX_H regexp ? regexec(&preg, str->str, 0, NULL, 0) == 0 : |