Skip to content

Commit

Permalink
Render correct document path on view scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
pathwave committed Nov 5, 2022
1 parent 002189a commit 249f6e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2135,8 +2135,8 @@ fn global_refactor(cx: &mut Context) {
let show_refactor = async move {
let all_matches: Vec<(PathBuf, usize, String)> =
UnboundedReceiverStream::new(all_matches_rx).collect().await;
let call: job::Callback =
Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
let call: job::Callback = Callback::EditorCompositor(Box::new(
move |editor: &mut Editor, compositor: &mut Compositor| {
if all_matches.is_empty() {
editor.set_status("No matches found");
return;
Expand All @@ -2159,7 +2159,8 @@ fn global_refactor(cx: &mut Context) {
let re_view =
ui::RefactorView::new(document_data, editor, editor_view, language_id);
compositor.push(Box::new(re_view));
});
},
));
Ok(call)
};
cx.jobs.callback(show_refactor);
Expand Down
5 changes: 3 additions & 2 deletions helix-term/src/ui/refactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,21 @@ impl RefactorView {
offset: helix_core::Position,
) {
let mut start = 0;
let mut count = 0;
for (key, value) in &self.matches {
for (line, _) in value {
if start >= offset.row {
let text = key.display().to_string() + ":" + line.to_string().as_str();
surface.set_string_truncated(
area.x as u16,
area.y + start as u16,
area.y + count as u16,
&text,
15,
|_| Style::default().fg(helix_view::theme::Color::Magenta),
true,
true,
);
count += 1;
}
start += 1;
}
Expand Down Expand Up @@ -351,7 +353,6 @@ impl Component for RefactorView {
},
_ => (),
}

EventResult::Ignored(None)
}

Expand Down

0 comments on commit 249f6e6

Please sign in to comment.