feat: Improve look of Global Search Picker (#12855)
Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com> Co-authored-by: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
This commit is contained in:
parent
1e8774a030
commit
682967d328
1 changed files with 30 additions and 3 deletions
|
@ -11,7 +11,10 @@ use helix_stdx::{
|
|||
};
|
||||
use helix_vcs::{FileChange, Hunk};
|
||||
pub use lsp::*;
|
||||
use tui::text::Span;
|
||||
use tui::{
|
||||
text::{Span, Spans},
|
||||
widgets::Cell,
|
||||
};
|
||||
pub use typed::*;
|
||||
|
||||
use helix_core::{
|
||||
|
@ -2404,18 +2407,42 @@ fn global_search(cx: &mut Context) {
|
|||
struct GlobalSearchConfig {
|
||||
smart_case: bool,
|
||||
file_picker_config: helix_view::editor::FilePickerConfig,
|
||||
directory_style: Style,
|
||||
number_style: Style,
|
||||
colon_style: Style,
|
||||
}
|
||||
|
||||
let config = cx.editor.config();
|
||||
let config = GlobalSearchConfig {
|
||||
smart_case: config.search.smart_case,
|
||||
file_picker_config: config.file_picker.clone(),
|
||||
directory_style: cx.editor.theme.get("ui.text.directory"),
|
||||
number_style: cx.editor.theme.get("constant.numeric.integer"),
|
||||
colon_style: cx.editor.theme.get("punctuation"),
|
||||
};
|
||||
|
||||
let columns = [
|
||||
PickerColumn::new("path", |item: &FileResult, _| {
|
||||
PickerColumn::new("path", |item: &FileResult, config: &GlobalSearchConfig| {
|
||||
let path = helix_stdx::path::get_relative_path(&item.path);
|
||||
format!("{}:{}", path.to_string_lossy(), item.line_num + 1).into()
|
||||
|
||||
let directories = path
|
||||
.parent()
|
||||
.filter(|p| !p.as_os_str().is_empty())
|
||||
.map(|p| format!("{}{}", p.display(), std::path::MAIN_SEPARATOR))
|
||||
.unwrap_or_default();
|
||||
|
||||
let filename = item
|
||||
.path
|
||||
.file_name()
|
||||
.expect("global search paths are normalized (can't end in `..`)")
|
||||
.to_string_lossy();
|
||||
|
||||
Cell::from(Spans::from(vec![
|
||||
Span::styled(directories, config.directory_style),
|
||||
Span::raw(filename),
|
||||
Span::styled(":", config.colon_style),
|
||||
Span::styled((item.line_num + 1).to_string(), config.number_style),
|
||||
]))
|
||||
}),
|
||||
PickerColumn::hidden("contents"),
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue