From eb8d73f5aa70b92a84eab2f04479c709ed95a820 Mon Sep 17 00:00:00 2001 From: riccardo Date: Mon, 16 Oct 2023 14:26:52 +0200 Subject: [PATCH] fix highlighting of literal match --- druid/src/main.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/druid/src/main.rs b/druid/src/main.rs index 1d7a134..1b17952 100644 --- a/druid/src/main.rs +++ b/druid/src/main.rs @@ -328,9 +328,11 @@ impl AppDelegate for Delegate { data.interim_count = 0; data.re_name = RegexBuilder::new(&data.text_name).case_insensitive(!data.name_case_sensitive).build(); - data.re_content = RegexBuilder::new(&data.text_contents) - .case_insensitive(!data.content_case_sensitive) - .build(); + let mut pattern = data.text_contents.to_string(); + if data.content_nonregex { + pattern = regex::escape(&pattern); + } + data.re_content = RegexBuilder::new(&pattern).case_insensitive(!data.content_case_sensitive).build(); data.message = rich("Searching...", Color::YELLOW); data.error_message = String::new();