on master help sign in
allow smart case in global search (#781)
432bec1Leoi Hung Kin
helix-term/src/commands.rs+7−2
@@ -43,7 +43,7 @@ use std::{
43use once_cell::sync::Lazy;
43use once_cell::sync::Lazy;
44use serde::de::{self, Deserialize, Deserializer};
44use serde::de::{self, Deserialize, Deserializer};
45
45
46−use grep_regex::RegexMatcher;
46+use grep_regex::RegexMatcherBuilder;
47use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
47use grep_searcher::{sinks, BinaryDetection, SearcherBuilder};
48use ignore::{DirEntry, WalkBuilder, WalkState};
48use ignore::{DirEntry, WalkBuilder, WalkState};
49use tokio_stream::wrappers::UnboundedReceiverStream;
49use tokio_stream::wrappers::UnboundedReceiverStream;
@@ -1226,6 +1226,7 @@ fn search_selection(cx: &mut Context) {
1226fn global_search(cx: &mut Context) {
1226fn global_search(cx: &mut Context) {
1227 let (all_matches_sx, all_matches_rx) =
1227 let (all_matches_sx, all_matches_rx) =
1228 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
1228 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
1229+ let smart_case = cx.editor.config.smart_case;
1229 let prompt = ui::regex_prompt(
1230 let prompt = ui::regex_prompt(
1230 cx,
1231 cx,
1231 "global search:".into(),
1232 "global search:".into(),
@@ -1234,7 +1235,11 @@ fn global_search(cx: &mut Context) {
1234 if event != PromptEvent::Validate {
1235 if event != PromptEvent::Validate {
1235 return;
1236 return;
1236 }
1237 }
1237− if let Ok(matcher) = RegexMatcher::new_line_matcher(regex.as_str()) {
1238+
1239+ if let Ok(matcher) = RegexMatcherBuilder::new()
1240+ .case_smart(smart_case)
1241+ .build(regex.as_str())
1242+ {
1238 let searcher = SearcherBuilder::new()
1243 let searcher = SearcherBuilder::new()
1239 .binary_detection(BinaryDetection::quit(b'\x00'))
1244 .binary_detection(BinaryDetection::quit(b'\x00'))
1240 .build();
1245 .build();