Attempts to complete a file path at the given position in the line
(
&self,
line: &str,
pos: usize,
os: &Context<'_>,
)
| 187 | |
| 188 | /// Attempts to complete a file path at the given position in the line |
| 189 | pub fn complete_path( |
| 190 | &self, |
| 191 | line: &str, |
| 192 | pos: usize, |
| 193 | os: &Context<'_>, |
| 194 | ) -> Result<(usize, Vec<String>), ReadlineError> { |
| 195 | // Use the filename completer to get path completions |
| 196 | match self.filename_completer.complete(line, pos, os) { |
| 197 | Ok((pos, completions)) => { |
| 198 | // Convert the filename completer's pairs to strings |
| 199 | let file_completions: Vec<String> = completions.iter().map(|pair| pair.replacement.clone()).collect(); |
| 200 | |
| 201 | // Return the completions if we have any |
| 202 | Ok((pos, file_completions)) |
| 203 | }, |
| 204 | Err(err) => Err(err), |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | pub struct PromptCompleter { |