@@ -27,7 +27,7 @@ use std::{collections::HashMap, io::Read, path::PathBuf};
28use crate::ui::{Prompt, PromptEvent};
28use crate::ui::{Prompt, PromptEvent};
29use helix_core::{
29use helix_core::{
30− movement::Direction, text_annotations::TextAnnotations,
30+ char_idx_at_visual_offset, movement::Direction, text_annotations::TextAnnotations,
31 unicode::segmentation::UnicodeSegmentation, Position, Syntax,
31 unicode::segmentation::UnicodeSegmentation, Position, Syntax,
33use helix_view::{
33use helix_view::{
@@ -690,20 +690,20 @@ impl<T: Item + 'static> Picker<T> {
693+ let mut offset = ViewPosition::default();
694+ if let Some(range) = range {
695+ let text_fmt = doc.text_format(inner.width, None);
696+ let annotations = TextAnnotations::default();
697+ (offset.anchor, offset.vertical_offset) = char_idx_at_visual_offset(
698+ doc.text().slice(..),
699+ doc.text().line_to_char(range.0),
693− // align to middle
700+ // align to middle
694− let first_line = range
695− .map(|(start, end)| {
696− let height = end.saturating_sub(start) + 1;
697− let middle = start + (height.saturating_sub(1) / 2);
698− middle.saturating_sub(inner.height as usize / 2).min(start)
701+ -(inner.height as isize / 2),
700− .unwrap_or(0);
703+ &text_fmt,
702− let offset = ViewPosition {
705+ );
703− anchor: doc.text().line_to_char(first_line),
704− horizontal_offset: 0,
708 let mut highlights = EditorView::doc_syntax_highlights(
708 let mut highlights = EditorView::doc_syntax_highlights(