From 561750c111578d5a5be952b477ffea7ae0d75658 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sun, 23 Aug 2026 18:20:07 +0100 Subject: [PATCH] Simply search function --- src/Widgets/SearchBar.vala | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/src/Widgets/SearchBar.vala b/src/Widgets/SearchBar.vala index 54efbf8f30..8271bdbd79 100644 --- a/src/Widgets/SearchBar.vala +++ b/src/Widgets/SearchBar.vala @@ -305,6 +305,7 @@ namespace Scratch.Widgets { this.text_buffer = text_view.get_buffer (); this.text_buffer.changed.connect (on_text_buffer_changed); this.search_context = new Gtk.SourceSearchContext (text_buffer as Gtk.SourceBuffer, null); + search_context.highlight = true; // There are no circumstances where we do not highlight search_context.settings.wrap_around = cycle_search_button.active; search_context.settings.regex_enabled = regex_search_button.active; search_context.settings.search_text = search_entry.text; @@ -385,19 +386,10 @@ namespace Scratch.Widgets { public bool search () { search_entry.grab_focus (); - if (search_context == null) { - return false; - } - - search_context.highlight = false; - - if (!has_matches ()) { - debug ("Can't search anything in a non-existent buffer and/or without anything to search."); + if (search_context == null || text_buffer == null || search_entry.text == "") { return false; } - search_context.highlight = true; - Gtk.TextIter? start_iter, end_iter; text_buffer.get_iter_at_offset (out start_iter, text_buffer.cursor_position); @@ -422,23 +414,6 @@ namespace Scratch.Widgets { return true; } - public void highlight_none () { - if (search_context != null) { - search_context.highlight = false; - } - } - - private bool has_matches () { - if (text_buffer == null || search_entry.text == "") { - return false; - } - - bool has_wrapped_around; - Gtk.TextIter? start_iter, end_iter; - text_buffer.get_start_iter (out start_iter); - return search_context.forward (start_iter, out start_iter, out end_iter, out has_wrapped_around); - } - private bool search_for_iter (Gtk.TextIter? start_iter, out Gtk.TextIter? end_iter) { end_iter = start_iter;