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

display the full path after the CD command with the TAB key #351

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
12 changes: 7 additions & 5 deletions src/ui/views/tui_textfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,26 @@ fn autocomplete(
if let Some(ref mut ct) = completion_tracker {
ct.index = if reversed {
ct.index.checked_sub(1).unwrap_or(ct.candidates.len() - 1)
} else if ct.index + 1 < ct.candidates.len() {
ct.index + 1
} else {
ct.index
(ct.index + 1) % ct.candidates.len()
Copy link
Owner

Choose a reason for hiding this comment

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

I prefer the autocomplete suggestions does not loop itself.
If a user would like to go back on a suggestion, one can use reverse order or restart the autocomplete by typing something.

};

let candidate = &ct.candidates[ct.index];
completer.update(line_buffer, ct.pos, candidate.display());
completer.update(line_buffer, ct.pos, candidate.replacement());
} else if let Some((pos, mut candidates)) = get_candidates(completer, line_buffer) {
if !candidates.is_empty() {
if candidates.len() == 1 && candidates[0].replacement().ends_with('/') {
completer.update(line_buffer, pos, &candidates[0].replacement());
return false;
}
candidates.sort_by(|x, y| {
x.display()
.partial_cmp(y.display())
.unwrap_or(std::cmp::Ordering::Less)
});

let first_idx = if reversed { candidates.len() - 1 } else { 0 };
let first = candidates[first_idx].display().to_string();
let first = candidates[first_idx].replacement().to_string();

let mut ct =
CompletionTracker::new(pos, candidates, String::from(line_buffer.as_str()));
Expand Down