Skip to content
This repository has been archived by the owner on Oct 20, 2024. It is now read-only.

Commit

Permalink
fix: better listing and completion
Browse files Browse the repository at this point in the history
  • Loading branch information
sehnryr committed Mar 24, 2023
1 parent 2b9dcc2 commit 4192e77
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/shell/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,26 @@ impl Completer for Helper<'_> {
if child_directory.borrow().name().starts_with(uncompleted) {
candidates.push(format!(
"{}/",
child_directory.borrow().path().display().to_string()
&child_directory.borrow().path().display().to_string()
[current_dir.display().to_string().len()..]
));
}
}

// Get matching files
for child_file in current_dir_node.borrow().children_files() {
if child_file.borrow().name().starts_with(uncompleted) {
candidates.push(child_file.borrow().path().display().to_string());
candidates.push(
child_file.borrow().path().display().to_string()
[current_dir.display().to_string().len()..].to_string(),
);
}
}

Ok((last_arg_pos, candidates))
// Sort the candidates
candidates.sort();

Ok((last_arg_pos + arg_path.len(), candidates))
}

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str) {
Expand Down

0 comments on commit 4192e77

Please sign in to comment.