diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 880d530f1..5dd982c09 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -77,6 +77,7 @@ impl<'a> Shell<'a> { sigint_handle: ctrl_c } } + fn readln(&mut self) -> Option { let vars_ptr = &self.variables as *const Variables; let dirs_ptr = &self.directory_stack as *const DirectoryStack; @@ -103,10 +104,17 @@ impl<'a> Shell<'a> { CursorPosition::InSpace(None, _) => false, CursorPosition::OnWordLeftEdge(index) => index >= 1, CursorPosition::OnWordRightEdge(index) => { - index >= 1 && !words.into_iter().nth(index).map(|(start, end)| { - let buf = editor.current_buffer(); - buf.range(start, end).trim().starts_with('$') - }).unwrap_or(false) + if let Some((start, end)) = words.into_iter().nth(index) { + if let Ok(mut file) = env::current_dir() { + let filename = editor.current_buffer().range(start, end); + file.push(filename); + file.exists() || file.parent().map(Path::exists).unwrap_or(false) + } else { + false + } + } else { + false + } } };