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

Implement Ord for MatchedPath to make its iterator sortable #30

Closed
yykamei opened this issue May 26, 2021 · 0 comments · Fixed by #33
Closed

Implement Ord for MatchedPath to make its iterator sortable #30

yykamei opened this issue May 26, 2021 · 0 comments · Fixed by #33
Labels
enhancement New feature or request
Milestone

Comments

@yykamei
Copy link
Owner

yykamei commented May 26, 2021

It's useful if an iterator of MatchedPath is sortable.

thwack/src/cli.rs

Lines 171 to 175 in 227603e

// TODO: Sort
for path in Finder::new(starting_point, query)?.take(limit.into()) {
let path = path?;
paths.push(path);
}

I want to make this comparison algorithm based on positions and relative. Each element of positions is usually adjacent to each other when the specified query is completely included in the MatchedPath (e.g., given query is foo.txt, MatchedPath with src/foo.txt should precede the one with src/components/footer/info.txt). Maybe, the directory depth of the file path might be a factor of sorting. This is the current definition of MatchedPath.

thwack/src/finder.rs

Lines 106 to 110 in 227603e

pub struct MatchedPath {
pub absolute: String,
pub relative: String,
pub positions: Vec<usize>,
}

@yykamei yykamei added the enhancement New feature or request label May 26, 2021
@yykamei yykamei added this to the v0.2.0 milestone May 26, 2021
@yykamei yykamei added no-changelog Excluded from CHANGELOG and removed no-changelog Excluded from CHANGELOG labels May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant