mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Add Reedline::has_last_command_context to allow checking if update_last_command_context will fail (#470)
This is necessary to avoid the problem with running executehostcommand keybindings in nushell right after launching it (without having run actual user-input commands yet). Since the error types are not exposed outside of the crate, we have to use a check instead of matching on the error.
This commit is contained in:
parent
069d902bcb
commit
fe889ae5c4
@ -377,6 +377,14 @@ impl Reedline {
|
|||||||
self.history.sync()
|
self.history.sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if any commands have been run.
|
||||||
|
///
|
||||||
|
/// When no commands have been run, calling [`Self::update_last_command_context`]
|
||||||
|
/// does not make sense and is guaranteed to fail with a "No command run" error.
|
||||||
|
pub fn has_last_command_context(&self) -> bool {
|
||||||
|
self.history_last_run_id.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
/// update the last history item with more information
|
/// update the last history item with more information
|
||||||
pub fn update_last_command_context(
|
pub fn update_last_command_context(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
Loading…
Reference in New Issue
Block a user