mirror of
https://github.com/nushell/reedline.git
synced 2024-09-11 15:55:50 +03:00
Fix rendering prompt after ExecuteHostCommand (#758)
* Fix rendering prompt after ExecuteHostCommand * Update src/engine.rs Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com> * Rename --------- Co-authored-by: Stefan Holderbach <sholderbach@users.noreply.github.com>
This commit is contained in:
parent
c7c17442e0
commit
4fd129588a
@ -109,6 +109,9 @@ pub struct Reedline {
|
|||||||
history_cursor_on_excluded: bool,
|
history_cursor_on_excluded: bool,
|
||||||
input_mode: InputMode,
|
input_mode: InputMode,
|
||||||
|
|
||||||
|
// Yielded to the host program after a `ReedlineEvent::ExecuteHostCommand`, thus redraw in-place
|
||||||
|
executing_host_command: bool,
|
||||||
|
|
||||||
// Validator
|
// Validator
|
||||||
validator: Option<Box<dyn Validator>>,
|
validator: Option<Box<dyn Validator>>,
|
||||||
|
|
||||||
@ -207,6 +210,7 @@ impl Reedline {
|
|||||||
history_excluded_item: None,
|
history_excluded_item: None,
|
||||||
history_cursor_on_excluded: false,
|
history_cursor_on_excluded: false,
|
||||||
input_mode: InputMode::Regular,
|
input_mode: InputMode::Regular,
|
||||||
|
executing_host_command: false,
|
||||||
painter,
|
painter,
|
||||||
transient_prompt: None,
|
transient_prompt: None,
|
||||||
edit_mode,
|
edit_mode,
|
||||||
@ -667,8 +671,12 @@ impl Reedline {
|
|||||||
/// Helper implementing the logic for [`Reedline::read_line()`] to be wrapped
|
/// Helper implementing the logic for [`Reedline::read_line()`] to be wrapped
|
||||||
/// in a `raw_mode` context.
|
/// in a `raw_mode` context.
|
||||||
fn read_line_helper(&mut self, prompt: &dyn Prompt) -> Result<Signal> {
|
fn read_line_helper(&mut self, prompt: &dyn Prompt) -> Result<Signal> {
|
||||||
|
if self.executing_host_command {
|
||||||
|
self.executing_host_command = false;
|
||||||
|
} else {
|
||||||
self.painter.initialize_prompt_position()?;
|
self.painter.initialize_prompt_position()?;
|
||||||
self.hide_hints = false;
|
self.hide_hints = false;
|
||||||
|
}
|
||||||
|
|
||||||
self.repaint(prompt)?;
|
self.repaint(prompt)?;
|
||||||
|
|
||||||
@ -765,8 +773,10 @@ impl Reedline {
|
|||||||
for event in reedline_events.drain(..) {
|
for event in reedline_events.drain(..) {
|
||||||
match self.handle_event(prompt, event)? {
|
match self.handle_event(prompt, event)? {
|
||||||
EventStatus::Exits(signal) => {
|
EventStatus::Exits(signal) => {
|
||||||
|
if !self.executing_host_command {
|
||||||
// Move the cursor below the input area, for external commands or new read_line call
|
// Move the cursor below the input area, for external commands or new read_line call
|
||||||
self.painter.move_cursor_to_end()?;
|
self.painter.move_cursor_to_end()?;
|
||||||
|
}
|
||||||
return Ok(signal);
|
return Ok(signal);
|
||||||
}
|
}
|
||||||
EventStatus::Handled => {
|
EventStatus::Handled => {
|
||||||
@ -842,6 +852,7 @@ impl Reedline {
|
|||||||
}
|
}
|
||||||
ReedlineEvent::ExecuteHostCommand(host_command) => {
|
ReedlineEvent::ExecuteHostCommand(host_command) => {
|
||||||
// TODO: Decide if we need to do something special to have a nicer painter state on the next go
|
// TODO: Decide if we need to do something special to have a nicer painter state on the next go
|
||||||
|
self.executing_host_command = true;
|
||||||
Ok(EventStatus::Exits(Signal::Success(host_command)))
|
Ok(EventStatus::Exits(Signal::Success(host_command)))
|
||||||
}
|
}
|
||||||
ReedlineEvent::Edit(commands) => {
|
ReedlineEvent::Edit(commands) => {
|
||||||
@ -1112,6 +1123,7 @@ impl Reedline {
|
|||||||
}
|
}
|
||||||
ReedlineEvent::ExecuteHostCommand(host_command) => {
|
ReedlineEvent::ExecuteHostCommand(host_command) => {
|
||||||
// TODO: Decide if we need to do something special to have a nicer painter state on the next go
|
// TODO: Decide if we need to do something special to have a nicer painter state on the next go
|
||||||
|
self.executing_host_command = true;
|
||||||
Ok(EventStatus::Exits(Signal::Success(host_command)))
|
Ok(EventStatus::Exits(Signal::Success(host_command)))
|
||||||
}
|
}
|
||||||
ReedlineEvent::Edit(commands) => {
|
ReedlineEvent::Edit(commands) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user