diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 919ddc2260dc..cbb098113498 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -489,7 +489,7 @@ impl Picker { }, }; } - + /// 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(); @@ -902,7 +902,7 @@ impl Picker { preview_scroll_offset = (Direction::Forward, 0); self.cursor_picker = self.cursor; } - + if let Some((preview, range)) = self.get_preview(cx.editor) { let doc = match preview.document() { Some(doc) @@ -920,8 +920,8 @@ impl Picker { return; } }; - let doc_height = doc.text().len_lines(); - + let doc_height = doc.text().len_lines(); + let mut offset = ViewPosition::default(); if let Some((start_line, end_line)) = range { let height = end_line - start_line; @@ -958,12 +958,12 @@ impl Picker { .saturating_sub(inner.height as usize), ), }; - + offset.vertical_offset = match preview_scroll_offset.0 { Direction::Backward => offset.anchor.saturating_sub(preview_scroll_offset.1), Direction::Forward => offset.anchor.saturating_add(preview_scroll_offset.1), - }; - + }; + let syntax_highlights = EditorView::doc_syntax_highlights( doc, offset.anchor, @@ -1015,7 +1015,7 @@ impl Picker { ); self.preview_scroll_offset = preview_scroll_offset; - + let win_height = inner.height as usize; let len = doc_height; let fits = len <= win_height; @@ -1045,7 +1045,7 @@ impl Picker { cell.set_fg(scroll_style.bg.unwrap_or(helix_view::theme::Color::Reset)); } } - } + } } } } @@ -1179,8 +1179,8 @@ impl Component for Picker { self.move_preview_by( - ctx.editor.config().scroll_lines.unsigned_abs(), - Direction::Backward, + ctx.editor.config().scroll_lines.unsigned_abs(), + Direction::Backward, ); } alt!('j') | shift!(Down) if self.show_preview => { @@ -1206,7 +1206,7 @@ impl Component for Picker { self.move_preview_by(self.preview_height as usize, Direction::Forward); - } + } _ => { self.prompt_handle_event(event, ctx); } @@ -1228,8 +1228,8 @@ impl Component for Picker Option<(u16, u16)> { self.completion_height = height.saturating_sub(4 + self.header_height()); - self.preview_height = height.saturating_sub(2); - + self.preview_height = height.saturating_sub(2); + Some((width, height)) }