Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show file preview in split pane in fuzzy finder #534

Merged
merged 21 commits into from
Aug 12, 2021

Conversation

sudormrfbin
Copy link
Member

@sudormrfbin sudormrfbin commented Jul 30, 2021

Screenshot_2021-08-03_15-23-49

TODO

  • Add preview for:
    • File picker
    • Buffer picker
    • Symbol picker
    • Goto {reference, implementation}
  • Fix lagging caused by tree sitter (cache ?)
  • Fix preview not being shown for the first item when opened
  • Reuse EditorView::render_buffer()
  • Code action should use normal picker

Bugs

  • File picker has directories in the list and panics (caused by symlinks)
  • Last line of preview not highlighted:
    let height = self.area.height.saturating_sub(1); // - 1 for statusline

@sudormrfbin sudormrfbin marked this pull request as ready for review July 31, 2021 15:09
Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool but I have some concerns about performance, the loading should probably be async. Kind of hard to make it work with the current system though.

helix-term/src/ui/picker.rs Outdated Show resolved Hide resolved
helix-term/src/ui/picker.rs Outdated Show resolved Hide resolved
helix-term/src/ui/picker.rs Outdated Show resolved Hide resolved
helix-term/src/ui/picker.rs Outdated Show resolved Hide resolved
The current selected item is cloned on every event, which is
undesirable
@archseer
Copy link
Member

I think this is good enough to merge after you resolve that last TODO :)

@sudormrfbin
Copy link
Member Author

Done :)

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor nits!

for layer in &self.layers {
layer.render(area, surface, cx)
for layer in &mut self.layers {
layer.prepare_for_render(cx);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't you just do this in render()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require changing render() to take a mutable ref to self, since it calculates the preview and stores it in the cache. I didn't want to do that since having a render function that could potentially change the state seemed like questionable design; should I simply have render() take &mut self ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The signature of render already takes a mut: pub fn render(&mut self, cx: &mut Context) I think I changed that for some ui component previously for the same reasons.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant Component's render function actually; changed it to take &mut self anyway since the topmost render takes mutable reference anyway.

helix-term/src/ui/mod.rs Outdated Show resolved Hide resolved
helix-term/src/ui/picker.rs Outdated Show resolved Hide resolved
helix-view/src/document.rs Outdated Show resolved Hide resolved
helix-core/src/selection.rs Outdated Show resolved Hide resolved
helix-term/src/commands.rs Show resolved Hide resolved
helix-term/src/ui/picker.rs Show resolved Hide resolved
@archseer
Copy link
Member

archseer commented Aug 12, 2021

I think you forgot to push the latest commits! I'll do a review once those are up.

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 🎉

@archseer archseer merged commit d84f8b5 into helix-editor:master Aug 12, 2021
@sudormrfbin sudormrfbin deleted the fuzzy-finder-preview branch December 17, 2021 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants