diff --git a/README.md b/README.md index 5bd1926b..dc40462d 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ You can call `with_autocomplete()` and provide a value that implements the `Auto For example, in the `complex_autocompletion.rs` example file, the `FilePathCompleter` scans the file system based on the current text input, storing a list of paths that match the current text input. -Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar how terminals work when traversing paths. +Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar to how terminals work when traversing paths. ### Default behaviors diff --git a/examples/complex_autocompletion.rs b/examples/complex_autocompletion.rs index ffb29848..a87ef614 100644 --- a/examples/complex_autocompletion.rs +++ b/examples/complex_autocompletion.rs @@ -6,6 +6,11 @@ use inquire::{ }; fn main() { + eprintln!("This is in no way representative of best practices when dealing with file systems and OS calls"); + eprintln!(); + eprintln!("It is a simple example to showcase autocompletion features and has not been battle-tested nor tested against bugs."); + eprintln!(); + let current_dir = std::env::current_dir().unwrap(); let help_message = format!("Current directory: {}", current_dir.to_string_lossy()); diff --git a/src/autocompletion.rs b/src/autocompletion.rs index aff89538..513c0dc4 100644 --- a/src/autocompletion.rs +++ b/src/autocompletion.rs @@ -28,7 +28,7 @@ pub type Replacement = Option; /// /// For example, in the `complex_autocompletion.rs` example file, the `FilePathCompleter` scans the file system based on the current text input, storing a list of paths that match the current text input. /// -/// Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar how terminals work when traversing paths. +/// Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar to how terminals work when traversing paths. pub trait Autocomplete: DynClone { /// List of input suggestions to be displayed to the user upon typing the /// text input. diff --git a/src/prompts/text.rs b/src/prompts/text.rs index a09e144b..5f69d7bb 100644 --- a/src/prompts/text.rs +++ b/src/prompts/text.rs @@ -52,7 +52,7 @@ const DEFAULT_HELP_MESSAGE_WITH_AC: &str = "↑↓ to move, tab to autocomplete, /// /// For example, in the `complex_autocompletion.rs` example file, the `FilePathCompleter` scans the file system based on the current text input, storing a list of paths that match the current text input. /// -/// Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar how terminals work when traversing paths. +/// Everytime `get_suggestions` is called, the method returns the list of paths that match the user input. When the user presses the autocompletion hotkey, the `FilePathCompleter` checks whether there is any path selected from the list, if there is, it decides to replace the current text input for it. The interesting piece of functionality is that if there isn't a path selected from the list, the `FilePathCompleter` calculates the longest common prefix amongst all scanned paths and updates the text input to an unambiguous new value. Similar to how terminals work when traversing paths. /// /// # Example ///