Skip to content
Snippets Groups Projects
Unverified Commit 8944c16c authored by gwenn's avatar gwenn Committed by GitHub
Browse files

Merge pull request #151 from eminence/completions

Ignore all IO errors during completion
parents 851af7ea 852a6f27
No related branches found
No related tags found
No related merge requests found
......@@ -299,20 +299,30 @@ fn filename_complete(
};
let mut entries: Vec<Pair> = Vec::new();
for entry in try!(dir.read_dir()) {
let entry = try!(entry);
if let Some(s) = entry.file_name().to_str() {
if s.starts_with(file_name) {
if let Ok(metadata) = fs::metadata(entry.path()) {
let mut path = String::from(dir_name) + s;
if metadata.is_dir() {
path.push(sep);
// if dir doesn't exist, then don't offer any completions
if !dir.exists() {
return Ok(entries);
}
// if any of the below IO operations have errors, just ignore them
if let Ok(read_dir) = dir.read_dir() {
for entry in read_dir {
if let Ok(entry) = entry {
if let Some(s) = entry.file_name().to_str() {
if s.starts_with(file_name) {
if let Ok(metadata) = fs::metadata(entry.path()) {
let mut path = String::from(dir_name) + s;
if metadata.is_dir() {
path.push(sep);
}
entries.push(Pair {
display: String::from(s),
replacement: escape(path, esc_char, break_chars, quote),
});
} // else ignore PermissionDenied
}
entries.push(Pair {
display: String::from(s),
replacement: escape(path, esc_char, break_chars, quote),
});
} // else ignore PermissionDenied
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment