@@ -26,7 +26,7 @@ use helix_view::{
26pub const MIN_SCREEN_WIDTH_FOR_PREVIEW: u16 = 80;
26pub const MIN_SCREEN_WIDTH_FOR_PREVIEW: u16 = 80;
28/// File path and line number (used to align and highlight a line)
28/// File path and line number (used to align and highlight a line)
29−type FileLocation = (PathBuf, Option<usize>);
29+type FileLocation = (PathBuf, Option<(usize, usize)>);
31pub struct FilePicker<T> {
31pub struct FilePicker<T> {
32 picker: Picker<T>,
32 picker: Picker<T>,
@@ -113,14 +113,17 @@ impl<T: 'static> Component for FilePicker<T> {
114 block.render(preview_area, surface);
114 block.render(preview_area, surface);
116− if let Some((doc, line)) = self.current_file(cx.editor).and_then(|(path, line)| {
116+ if let Some((doc, line)) = self.current_file(cx.editor).and_then(|(path, range)| {
117 cx.editor
117 cx.editor
118 .document_by_path(&path)
118 .document_by_path(&path)
119 .or_else(|| self.preview_cache.get(&path))
119 .or_else(|| self.preview_cache.get(&path))
120− .zip(Some(line))
120+ .zip(Some(range))
122 // align to middle
122 // align to middle
123+ let first_line = line
124+ .map(|(start, _)| start)
123− let first_line = line.unwrap_or(0).saturating_sub(inner.height as usize / 2);
126+ .saturating_sub(inner.height as usize / 2);
124 let offset = Position::new(first_line, 0);
127 let offset = Position::new(first_line, 0);
126 let highlights = EditorView::doc_syntax_highlights(
129 let highlights = EditorView::doc_syntax_highlights(
@@ -140,12 +143,18 @@ impl<T: 'static> Component for FilePicker<T> {
142 // highlight the line
145 // highlight the line
143− if let Some(line) = line {
146+ if let Some((start, end)) = line {
144− for x in inner.left()..inner.right() {
147+ let offset = start.saturating_sub(first_line) as u16;
145− surface
148+ surface.set_style(
146− .get_mut(x, inner.y + line.saturating_sub(first_line) as u16)
153+ (end.saturating_sub(start) as u16 + 1)
154+ .min(inner.height.saturating_sub(offset)),
147− .set_style(cx.editor.theme.get("ui.selection"));
156+ cx.editor.theme.get("ui.selection"),