Skip to content

Commit 7b56ffa

Browse files
jeremypwzeebok
andauthored
Simplify search function (#1803)
* Simply search function * Lose unused has_matches () --------- Co-authored-by: Ryan Kornheisl <ryan@skarva.tech>
1 parent 42fbee2 commit 7b56ffa

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

‎src/Widgets/SearchBar.vala‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,10 @@ public class Scratch.Widgets.SearchBar : Gtk.Box { //TODO In Gtk4 use a BinLayou
313313

314314
public bool search () {
315315
search_entry.grab_focus ();
316-
if (search_context == null) {
316+
if (search_context == null || text_buffer == null || search_entry.text == "") {
317317
return false;
318318
}
319319

320-
search_context.highlight = false;
321-
322-
if (!has_matches ()) {
323-
debug ("Can't search anything in a non-existent buffer and/or without anything to search.");
324-
return false;
325-
}
326-
327-
search_context.highlight = true;
328-
329320
Gtk.TextIter? start_iter, end_iter;
330321
text_buffer.get_iter_at_offset (out start_iter, text_buffer.cursor_position);
331322

@@ -460,17 +451,6 @@ public class Scratch.Widgets.SearchBar : Gtk.Box { //TODO In Gtk4 use a BinLayou
460451
}
461452
}
462453

463-
private bool has_matches () {
464-
if (text_buffer == null || search_entry.text == "") {
465-
return false;
466-
}
467-
468-
bool has_wrapped_around;
469-
Gtk.TextIter? start_iter, end_iter;
470-
text_buffer.get_start_iter (out start_iter);
471-
return search_context.forward (start_iter, out start_iter, out end_iter, out has_wrapped_around);
472-
}
473-
474454
private bool search_for_iter (Gtk.TextIter? start_iter, out Gtk.TextIter? end_iter) {
475455
end_iter = start_iter;
476456

0 commit comments

Comments
 (0)