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

Trim leading whitespaces in file search #2585

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helix-term/src/ui/picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl<T> Picker<T> {
pub fn score(&mut self) {
let now = Instant::now();

let pattern = self.prompt.line();
let pattern = &self.prompt.line().trim_start().to_string();
Copy link
Contributor

Choose a reason for hiding this comment

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

The to_string() allocation is only necessary for line 422, which does another clone. I would remove here the &...to_string() and put in 422 self.previous_pattern = pattern.to_string();


if pattern == &self.previous_pattern {
return;
Expand Down Expand Up @@ -618,7 +618,7 @@ impl<T: 'static> Component for Picker<T> {

let (_score, highlights) = self
.matcher
.fuzzy_indices(&formatted, self.prompt.line())
.fuzzy_indices(&formatted, self.prompt.line().trim_start())
.unwrap_or_default();

surface.set_string_truncated(
Expand Down