feat: add placeholder line content in local_search result

Display placeholder line content with local_search result.
Since columns expect a fn and not a closure it proved challenging
to extract data from cx.editor without borrowing cx within the scope.

For now a placeholder line content is placed until we fix this.
pull/13053/head
oxcrow 2025-03-13 23:27:02 +05:30
parent e37265e16f
commit fc7955094d
No known key found for this signature in database
GPG Key ID: 2057528A3E83A137
1 changed files with 15 additions and 7 deletions

View File

@ -2679,13 +2679,21 @@ fn local_search(cx: &mut Context) {
let columns = [ let columns = [
PickerColumn::new("path", |item: &FileResult, config: &LocalSearchConfig| { PickerColumn::new("path", |item: &FileResult, config: &LocalSearchConfig| {
Cell::from(Spans::from( let line_num = (item.line_num + 1).to_string();
// only show line numbers in the left picker column // files can never contain more than 999_999_999_999 lines
vec![Span::styled( // thus using maximum line length to be 12 for this formatter is valid
(item.line_num + 1).to_string(), let max_line_num_length = 12;
config.number_style, // whitespace padding to align results after the line number
)], let padding_length = max_line_num_length - line_num.len();
)) let padding = " ".repeat(padding_length);
// extract line content from the editor
let line_content = "<insert line content here>";
// create column value to be displayed in the picker
Cell::from(Spans::from(vec![
Span::styled(line_num, config.number_style),
Span::raw(padding),
Span::raw(line_content),
]))
}), }),
PickerColumn::hidden("contents"), PickerColumn::hidden("contents"),
]; ];