[gnome-text-editor] searchbar: always update search text to selection
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] searchbar: always update search text to selection
- Date: Tue, 22 Feb 2022 19:39:07 +0000 (UTC)
commit 3bcb064fb87ef81f3d1c443bbacbef6e4212a271
Author: Christian Hergert <chergert redhat com>
Date: Tue Feb 22 11:39:01 2022 -0800
searchbar: always update search text to selection
If we have a selection, then we always want to update that whether or not
we have setup a context already.
This fixes a situation where we search, go back to text editor, and then
search again with a new selection.
Fixes #313
src/editor-search-bar.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
---
diff --git a/src/editor-search-bar.c b/src/editor-search-bar.c
index 1bc03fa..c63acbd 100644
--- a/src/editor-search-bar.c
+++ b/src/editor-search-bar.c
@@ -588,25 +588,21 @@ _editor_search_bar_attach (EditorSearchBar *self,
{
GtkTextBuffer *buffer = (GtkTextBuffer *)document;
GtkTextIter begin, end, insert;
- const gchar *search;
g_return_if_fail (EDITOR_IS_SEARCH_BAR (self));
- if (self->context != NULL)
- return;
-
gtk_text_buffer_get_iter_at_mark (buffer, &insert, gtk_text_buffer_get_insert (buffer));
self->offset_when_shown = gtk_text_iter_get_offset (&insert);
- search = gtk_editable_get_text (GTK_EDITABLE (self->search_entry));
-
- if ((search == NULL || g_strcmp0 (search, "") == 0) &&
- gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (document), &begin, &end))
+ if (gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (document), &begin, &end))
{
g_autofree gchar *text = gtk_text_iter_get_slice (&begin, &end);
gtk_editable_set_text (GTK_EDITABLE (self->search_entry), text);
}
+ if (self->context != NULL)
+ return;
+
self->context = gtk_source_search_context_new (GTK_SOURCE_BUFFER (document), self->settings);
g_signal_connect_object (self->context,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]