mirror of https://github.com/helix-editor/helix
fix: separate line content in local_search result
Separate the line number and the line content rendering logic. Use "line" as column header instead of "path".pull/13053/head
parent
e2768a8b44
commit
8fba25bb86
|
@ -2680,7 +2680,7 @@ fn local_search(cx: &mut Context) {
|
||||||
};
|
};
|
||||||
|
|
||||||
let columns = [
|
let columns = [
|
||||||
PickerColumn::new("path", |item: &FileResult, config: &LocalSearchConfig| {
|
PickerColumn::new("line", |item: &FileResult, config: &LocalSearchConfig| {
|
||||||
let line_num = (item.line_num + 1).to_string();
|
let line_num = (item.line_num + 1).to_string();
|
||||||
// files can never contain more than 99_999_999 lines
|
// files can never contain more than 99_999_999 lines
|
||||||
// thus using maximum line length to be 8 for this formatter is valid
|
// thus using maximum line length to be 8 for this formatter is valid
|
||||||
|
@ -2688,16 +2688,18 @@ fn local_search(cx: &mut Context) {
|
||||||
// whitespace padding to align results after the line number
|
// whitespace padding to align results after the line number
|
||||||
let padding_length = max_line_num_length - line_num.len();
|
let padding_length = max_line_num_length - line_num.len();
|
||||||
let padding = " ".repeat(padding_length);
|
let padding = " ".repeat(padding_length);
|
||||||
// extract line content to be displayed in the picker
|
|
||||||
let line_content = item.line_content.clone();
|
|
||||||
// create column value to be displayed in the picker
|
// create column value to be displayed in the picker
|
||||||
Cell::from(Spans::from(vec![
|
Cell::from(Spans::from(vec![
|
||||||
Span::styled(line_num, config.number_style),
|
Span::styled(line_num, config.number_style),
|
||||||
Span::raw(padding),
|
Span::raw(padding),
|
||||||
Span::raw(line_content),
|
|
||||||
]))
|
]))
|
||||||
}),
|
}),
|
||||||
PickerColumn::hidden("contents"),
|
PickerColumn::new("", |item: &FileResult, _config: &LocalSearchConfig| {
|
||||||
|
// extract line content to be displayed in the picker
|
||||||
|
let line_content = item.line_content.clone();
|
||||||
|
// create column value to be displayed in the picker
|
||||||
|
Cell::from(Spans::from(vec![Span::raw(line_content)]))
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
let get_files = |query: &str,
|
let get_files = |query: &str,
|
||||||
|
|
Loading…
Reference in New Issue