diff options
| author | Vadim Barkov <[email protected]> | 2017-01-08 17:51:17 +0300 | 
|---|---|---|
| committer | Vadim Barkov <[email protected]> | 2017-01-08 17:51:17 +0300 | 
| commit | a79faa602fac4e4bb4c33a324150219727fa1f57 (patch) | |
| tree | c4fdd1fea4122c34d28faaa3a11d89758ef1577a | |
| parent | df3b18c149e4e410988242153b2d3f26b1601d0f (diff) | |
| download | pluma-a79faa602fac4e4bb4c33a324150219727fa1f57.tar.bz2 pluma-a79faa602fac4e4bb4c33a324150219727fa1f57.tar.xz | |
Fixed wrong behaviour of search on zero length results
| -rw-r--r-- | pluma/pluma-utils.c | 40 | 
1 files changed, 36 insertions, 4 deletions
| diff --git a/pluma/pluma-utils.c b/pluma/pluma-utils.c index d1c701ea..b8f081c0 100644 --- a/pluma/pluma-utils.c +++ b/pluma/pluma-utils.c @@ -1597,6 +1597,9 @@ pluma_gtk_text_iter_regex_search (const GtkTextIter *iter,  	gchar **all_matches;  	gchar *match_string;  	gboolean found; +    gint non_null_result_number; +    gboolean non_null_result_found; +    guint result_size;  	compile_flags = 0;  	if ((flags & GTK_TEXT_SEARCH_CASE_INSENSITIVE) != 0) @@ -1645,9 +1648,38 @@ pluma_gtk_text_iter_regex_search (const GtkTextIter *iter,  	if (found)  	{          all_matches = g_match_info_fetch_all (match_info); +        result_size = (gint) g_strv_length (all_matches); + +        if(forward_search){ +            non_null_result_number = 0; +        } else { +            non_null_result_number = result_size - 1 ; +        } +        non_null_result_found = FALSE; +        while((non_null_result_number >= 0) +              && (non_null_result_number < result_size) ) { + +            if(g_utf8_strlen (all_matches [non_null_result_number], G_MAXSSIZE) != 0) { +                non_null_result_found = TRUE; +                break; +            } else { +                if(forward_search) { +                    non_null_result_number++; +                } else { +                    non_null_result_number--; +                } +            } + +        } + +        if(!non_null_result_found) { +            found = FALSE; +            goto free_resources; +        } + +        match_string = all_matches [non_null_result_number];          if (forward_search) -		{ -            match_string = all_matches[0]; +        {              gtk_text_iter_forward_search (begin_iter,  						     match_string,  						     flags, @@ -1656,8 +1688,7 @@ pluma_gtk_text_iter_regex_search (const GtkTextIter *iter,  						     limit);  		}  		else -		{ -            match_string = all_matches[g_strv_length (all_matches) - 1]; +        {              gtk_text_iter_backward_search (begin_iter,  						      match_string,  						      flags, @@ -1667,6 +1698,7 @@ pluma_gtk_text_iter_regex_search (const GtkTextIter *iter,  		}  	} +free_resources:      gtk_text_iter_free (begin_iter);      gtk_text_iter_free (end_iter);  	g_match_info_free (match_info); | 
