aboutsummaryrefslogtreecommitdiff
path: root/main/src/ui/global_search.vala
diff options
context:
space:
mode:
authorhrxi <hrrrxi@gmail.com>2019-09-01 18:18:25 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2019-09-10 19:36:11 +0200
commitd5d305193ce527f1cc3022c406de35d9a85d4ccb (patch)
treed12efc741319a7d71c13f7bf6c2c7579d25fdabe /main/src/ui/global_search.vala
parent9950742bf1903291c271619aea101b0e2f81d19c (diff)
downloaddino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.tar.gz
dino-d5d305193ce527f1cc3022c406de35d9a85d4ccb.zip
Fix some warnings
Instances of `RegexError` are just asserted as `assert_not_reached` as they cannot really fail except for allocation failure if the given regex is valid.
Diffstat (limited to 'main/src/ui/global_search.vala')
-rw-r--r--main/src/ui/global_search.vala44
1 files changed, 24 insertions, 20 deletions
diff --git a/main/src/ui/global_search.vala b/main/src/ui/global_search.vala
index 73a61dc5..db7dbc0f 100644
--- a/main/src/ui/global_search.vala
+++ b/main/src/ui/global_search.vala
@@ -206,27 +206,31 @@ public class GlobalSearch : Overlay {
// Color the keywords
int elongated_by = 0;
- Regex highlight_regex = new Regex(regex_str);
- MatchInfo match_info;
- string markup_text_bak = markup_text.down();
- highlight_regex.match(markup_text_bak, 0, out match_info);
- for (; match_info.matches(); match_info.next()) {
- int start, end;
- match_info.fetch_pos(0, out start, out end);
- markup_text = markup_text[0:start+elongated_by] + "<span bgcolor=\"yellow\">" + markup_text[start+elongated_by:end+elongated_by] + "</span>" + markup_text[end+elongated_by:markup_text.length];
- elongated_by += "<span bgcolor=\"yellow\">".length + "</span>".length;
+ try {
+ Regex highlight_regex = new Regex(regex_str);
+ MatchInfo match_info;
+ string markup_text_bak = markup_text.down();
+ highlight_regex.match(markup_text_bak, 0, out match_info);
+ for (; match_info.matches(); match_info.next()) {
+ int start, end;
+ match_info.fetch_pos(0, out start, out end);
+ markup_text = markup_text[0:start+elongated_by] + "<span bgcolor=\"yellow\">" + markup_text[start+elongated_by:end+elongated_by] + "</span>" + markup_text[end+elongated_by:markup_text.length];
+ elongated_by += "<span bgcolor=\"yellow\">".length + "</span>".length;
+ }
+ markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string
+
+ label.label = markup_text;
+ grid.attach(label, 1, 1, 1, 1);
+
+ Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
+ button.clicked.connect(() => {
+ selected_item(item);
+ });
+ button.add(grid);
+ return button;
+ } catch (RegexError e) {
+ assert_not_reached();
}
- markup_text_bak += ""; // We need markup_text_bak to live until here because url_regex.match does not copy the string
-
- label.label = markup_text;
- grid.attach(label, 1, 1, 1, 1);
-
- Button button = new Button() { relief=ReliefStyle.NONE, visible=true };
- button.clicked.connect(() => {
- selected_item(item);
- });
- button.add(grid);
- return button;
}
private Grid get_context_message_widget(MessageItem item) {