summaryrefslogtreecommitdiffstats
path: root/ui/src/components
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-21 02:42:18 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2020-01-21 12:02:21 +0200
commit1e2acd3b296bd8afb480fee0f9d70db5f5542f3e (patch)
tree974aa8d70d749270d3e849d141adcc4fe1d30737 /ui/src/components
parent6d9f584de3430aa65f9a3e8a5907d0bb4bcd637a (diff)
melib: add complete() method to ShellExpandTrait
complete(force: bool) returns String path segments that when appended to the path will form a valid location. Example: - User types: save-attachment 1 /t - User presses <TAB>. - complete() returns the suggestion: "mp/" - User sees: save-attachment 1 /tmp/ complete() uses openat() and getdents64 syscalls hoping it's faster than using stdlib.
Diffstat (limited to 'ui/src/components')
-rw-r--r--ui/src/components/utilities.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs
index c8ea24a7..3a79be93 100644
--- a/ui/src/components/utilities.rs
+++ b/ui/src/components/utilities.rs
@@ -897,6 +897,19 @@ impl Component for StatusBar {
None
}
}));
+ if let Some(p) = self
+ .ex_buffer
+ .as_str()
+ .split_whitespace()
+ .last()
+ .map(std::path::Path::new)
+ {
+ suggestions.extend(
+ debug!(debug!(p).complete(true))
+ .into_iter()
+ .map(|m| format!("{}{}", self.ex_buffer.as_str(), m).into()),
+ );
+ }
if suggestions.is_empty() && !self.auto_complete.suggestions().is_empty() {
self.auto_complete.set_suggestions(suggestions);
/* redraw self.container because we have got ridden of an autocomplete