Skip to content

Commit

Permalink
Fix windows impl
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed Aug 31, 2024
1 parent 2f77007 commit 7465673
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl From<std::string::FromUtf8Error> for ReadlineError {
}
}

#[cfg(unix)]
#[cfg(any(unix, all(feature = "split-highlight", not(feature = "ansi-str"))))]
impl From<fmt::Error> for ReadlineError {
fn from(err: fmt::Error) -> Self {
Self::Io(io::Error::new(io::ErrorKind::Other, err))
Expand Down
17 changes: 16 additions & 1 deletion src/tty/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,22 @@ impl Renderer for ConsoleRenderer {
// append the prompt
col = self.wrap_at_eol(&highlighter.highlight_prompt(prompt, default_prompt), col);
// append the input line
col = self.wrap_at_eol(&highlighter.highlight(line, line.pos()), col);
cfg_if::cfg_if! {
if #[cfg(not(feature = "split-highlight"))] {
col = self.wrap_at_eol(&highlighter.highlight(line, line.pos()), col);
} else if #[cfg(feature = "ansi-str")] {
col = self.wrap_at_eol(&highlighter.highlight(line, line.pos()), col);
} else {
use std::fmt::Write;
use crate::highlight::{Style, StyledBlock};
for sb in highlighter.highlight_line(line, line.pos()) {
let style = sb.style();
write!(self.buffer, "{}", style.start())?;
col = self.wrap_at_eol(sb.text(), col);
write!(self.buffer, "{}", style.end())?;
}
}
}
} else if self.colors_enabled {
// append the prompt
col = self.wrap_at_eol(prompt, col);
Expand Down

0 comments on commit 7465673

Please sign in to comment.