Add fixed strings workspace search

pull/12929/head
Thomas Schafer 2025-02-21 10:34:08 +00:00
parent 0deb8bbce6
commit 55b3bd962b
No known key found for this signature in database
2 changed files with 15 additions and 2 deletions

View File

@ -79,7 +79,8 @@
| `search_selection` | Use current selection as search pattern | normal: `` <A-*> ``, select: `` <A-*> `` | | `search_selection` | Use current selection as search pattern | normal: `` <A-*> ``, select: `` <A-*> `` |
| `search_selection_detect_word_boundaries` | Use current selection as the search pattern, automatically wrapping with `\b` on word boundaries | normal: `` * ``, select: `` * `` | | `search_selection_detect_word_boundaries` | Use current selection as the search pattern, automatically wrapping with `\b` on word boundaries | normal: `` * ``, select: `` * `` |
| `make_search_word_bounded` | Modify current search to make it word bounded | | | `make_search_word_bounded` | Modify current search to make it word bounded | |
| `global_search` | Global search in workspace folder | normal: `` <space>/ ``, select: `` <space>/ `` | | `global_search` | Global search in workspace folder (regex) | normal: `` <space>/ ``, select: `` <space>/ `` |
| `global_search_fixed_strings` | Global search in workspace folder (fixed strings) | |
| `extend_line` | Select current line, if already selected, extend to another line based on the anchor | | | `extend_line` | Select current line, if already selected, extend to another line based on the anchor | |
| `extend_line_below` | Select current line, if already selected, extend to next line | normal: `` x ``, select: `` x `` | | `extend_line_below` | Select current line, if already selected, extend to next line | normal: `` x ``, select: `` x `` |
| `extend_line_above` | Select current line, if already selected, extend to previous line | | | `extend_line_above` | Select current line, if already selected, extend to previous line | |

View File

@ -372,7 +372,8 @@ impl MappableCommand {
search_selection, "Use current selection as search pattern", search_selection, "Use current selection as search pattern",
search_selection_detect_word_boundaries, "Use current selection as the search pattern, automatically wrapping with `\\b` on word boundaries", search_selection_detect_word_boundaries, "Use current selection as the search pattern, automatically wrapping with `\\b` on word boundaries",
make_search_word_bounded, "Modify current search to make it word bounded", make_search_word_bounded, "Modify current search to make it word bounded",
global_search, "Global search in workspace folder", global_search, "Global search in workspace folder (regex)",
global_search_fixed_strings, "Global search in workspace folder (fixed strings)",
extend_line, "Select current line, if already selected, extend to another line based on the anchor", extend_line, "Select current line, if already selected, extend to another line based on the anchor",
extend_line_below, "Select current line, if already selected, extend to next line", extend_line_below, "Select current line, if already selected, extend to next line",
extend_line_above, "Select current line, if already selected, extend to previous line", extend_line_above, "Select current line, if already selected, extend to previous line",
@ -2385,6 +2386,14 @@ fn make_search_word_bounded(cx: &mut Context) {
} }
fn global_search(cx: &mut Context) { fn global_search(cx: &mut Context) {
global_search_impl(cx, false)
}
fn global_search_fixed_strings(cx: &mut Context) {
global_search_impl(cx, true)
}
fn global_search_impl(cx: &mut Context, fixed_strings: bool) {
#[derive(Debug)] #[derive(Debug)]
struct FileResult { struct FileResult {
path: PathBuf, path: PathBuf,
@ -2403,12 +2412,14 @@ fn global_search(cx: &mut Context) {
struct GlobalSearchConfig { struct GlobalSearchConfig {
smart_case: bool, smart_case: bool,
fixed_strings: bool,
file_picker_config: helix_view::editor::FilePickerConfig, file_picker_config: helix_view::editor::FilePickerConfig,
} }
let config = cx.editor.config(); let config = cx.editor.config();
let config = GlobalSearchConfig { let config = GlobalSearchConfig {
smart_case: config.search.smart_case, smart_case: config.search.smart_case,
fixed_strings,
file_picker_config: config.file_picker.clone(), file_picker_config: config.file_picker.clone(),
}; };
@ -2441,6 +2452,7 @@ fn global_search(cx: &mut Context) {
let matcher = match RegexMatcherBuilder::new() let matcher = match RegexMatcherBuilder::new()
.case_smart(config.smart_case) .case_smart(config.smart_case)
.fixed_strings(config.fixed_strings)
.build(query) .build(query)
{ {
Ok(matcher) => { Ok(matcher) => {