Skip to content

Commit

Permalink
feat(Search): limit query bolding to regular sized results (GeopJr#1276)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Dec 15, 2024
1 parent 2cf496d commit 66397d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Views/Search.vala
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ public class Tuba.Views.Search : Views.TabbedBase {

GLib.Regex? search_query_regex = null;
private void generate_regex () {
if (this.query.length >= 45) return;

try {
search_query_regex = new Regex (
// "this is a test." => /(\bthis\b|\bis\b|\ba\b|\btest\.\b)/
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/MarkupView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public class Tuba.Widgets.MarkupView : Gtk.Box {
}

private static string bold_needle (owned string source, GLib.Regex? bold_text_regex) {
if (bold_text_regex == null) return source;
if (bold_text_regex == null || source.length >= 2000) return source;

try {
source = bold_text_regex.replace (source, source.length, 0, "<b>\\0</b>");
Expand Down

0 comments on commit 66397d8

Please sign in to comment.