-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
741f2f7
commit a1ee071
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use super::line::LineStateBundle; | ||
|
||
pub trait Suggester { | ||
fn suggest(&self, line_ctx: &LineStateBundle) -> Option<String>; | ||
} | ||
pub struct DefaultSuggester; | ||
impl Suggester for DefaultSuggester { | ||
fn suggest(&self, line_ctx: &LineStateBundle) -> Option<String> { | ||
let h = &line_ctx.ctx.history; | ||
let res = line_ctx.line.get_full_command(); | ||
if res.is_empty() { | ||
return None; | ||
} | ||
|
||
for i in 0..h.len() { | ||
if let Some(s) = h.get(i) { | ||
if s.starts_with(&res) { | ||
return Some(s.to_owned()); | ||
} | ||
} | ||
} | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters