summaryrefslogtreecommitdiffstats
path: root/src/render/repl.rs
diff options
context:
space:
mode:
authorAnthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com>2023-07-09 20:07:09 -0700
committerGitHub <noreply@github.com>2023-07-10 11:07:09 +0800
commit97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb (patch)
treec19390877425fa50049761e8ee6bc93f21c46f56 /src/render/repl.rs
parentec51b84290215d11d5045de8baa9b89f2447b1e9 (diff)
downloadaichat-97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb.tar.gz
fix: minor code cleanup and pedantic lints (#134)
Diffstat (limited to 'src/render/repl.rs')
-rw-r--r--src/render/repl.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/render/repl.rs b/src/render/repl.rs
index 04dee73..2bdf3b2 100644
--- a/src/render/repl.rs
+++ b/src/render/repl.rs
@@ -16,10 +16,11 @@ use std::{
};
use unicode_width::UnicodeWidthStr;
+#[allow(clippy::module_name_repetitions)]
pub fn repl_render_stream(
- rx: Receiver<ReplyStreamEvent>,
+ rx: &Receiver<ReplyStreamEvent>,
light_theme: bool,
- abort: SharedAbortSignal,
+ abort: &SharedAbortSignal,
) -> Result<()> {
enable_raw_mode()?;
let mut stdout = io::stdout();
@@ -32,9 +33,9 @@ pub fn repl_render_stream(
}
fn repl_render_stream_inner(
- rx: Receiver<ReplyStreamEvent>,
+ rx: &Receiver<ReplyStreamEvent>,
light_theme: bool,
- abort: SharedAbortSignal,
+ abort: &SharedAbortSignal,
writer: &mut Stdout,
) -> Result<()> {
let mut last_tick = Instant::now();
@@ -118,7 +119,8 @@ fn repl_render_stream_inner(
}
fn recover_cursor(writer: &mut Stdout, terminal_columns: u16, buffer: &str) -> Result<()> {
- let buffer_rows = (buffer.width() as u16 + terminal_columns - 1) / terminal_columns;
+ let buffer_rows = (u16::try_from(buffer.width()).unwrap_or(u16::MAX) + terminal_columns - 1)
+ / terminal_columns;
let (_, row) = cursor::position()?;
if buffer_rows == 0 {
queue!(writer, cursor::MoveTo(0, row))?;