Add grep syntax highlighting to global search picker

pull/13663/head
godalming123 2025-05-31 17:39:09 +01:00
parent 2baff46b25
commit 669174c7d1
3 changed files with 8 additions and 2 deletions

View File

@ -2661,7 +2661,8 @@ fn global_search(cx: &mut Context) {
Some((path.as_path().into(), Some((*line_num, *line_num))))
})
.with_history_register(Some(reg))
.with_dynamic_query(get_files, Some(275));
.with_dynamic_query(get_files, Some(275))
.with_language("regex", std::sync::Arc::clone(&cx.editor.syn_loader));
cx.push_layer(Box::new(overlaid(picker)));
}

View File

@ -440,6 +440,11 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
self
}
pub fn with_language(mut self, language: &'static str, loader: Arc<ArcSwap<Loader>>) -> Self {
self.prompt.language = Some((language, loader));
self
}
/// Move the cursor by a number of lines, either down (`Forward`) or up (`Backward`)
pub fn move_by(&mut self, amount: u32, direction: Direction) {
let len = self.matcher.snapshot().matched_item_count();

View File

@ -44,7 +44,7 @@ pub struct Prompt {
callback_fn: CallbackFn,
pub doc_fn: DocFn,
next_char_handler: Option<PromptCharHandler>,
language: Option<(&'static str, Arc<ArcSwap<syntax::Loader>>)>,
pub language: Option<(&'static str, Arc<ArcSwap<syntax::Loader>>)>,
}
#[derive(Clone, Copy, PartialEq, Eq)]