Do not show completion if already on an existing path

This commit is contained in:
Jeremy Soller 2025-02-07 10:26:19 -07:00
parent 868aa79127
commit bc4f267c60
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA

View file

@ -237,13 +237,14 @@ pub fn folder_icon_symbolic(path: &PathBuf, icon_size: u16) -> widget::icon::Han
fn tab_complete(path: &Path) -> Result<Vec<(String, PathBuf)>, Box<dyn Error>> {
let parent = if path.exists() {
path
// Do not show completion if already on an existing path
return Ok(Vec::new());
} else {
path.parent()
.ok_or_else(|| format!("path has no parent {:?}", path))?
};
let child_os = path.strip_prefix(&parent).unwrap_or_else(|_| Path::new(""));
let child_os = path.strip_prefix(&parent)?;
let child = child_os
.to_str()
.ok_or_else(|| format!("invalid UTF-8 {:?}", child_os))?;