Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/commands/config_cmds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,12 @@ pub(super) async fn cmd_backend(args: &str, state: &mut AppState) -> Result<()>
for (i, b) in BackendName::all().iter().enumerate() {
println!(" {DIM}{}){RESET} {}", i + 1, b.as_str());
}
// Blank line so the list and the prompt don't crowd each other.
println!();
let prompt = format!(" {DIM}Select (1-{}):{RESET} ", BackendName::all().len());
let pick = plain_read_line(prompt).await?.trim().to_string();
// Blank line between the typed selection and the response below.
println!();
pick.parse::<usize>()
.ok()
.and_then(|n| n.checked_sub(1))
Expand Down Expand Up @@ -633,8 +637,12 @@ pub(super) async fn cmd_model(args: &str, state: &mut AppState) -> Result<()> {
if total > shown.len() {
println!(" {DIM}…and {} more{RESET}", total - shown.len());
}
// Blank line so the list and the prompt don't crowd each other.
println!();
let prompt = format!(" {DIM}Select (1-{}):{RESET} ", shown.len());
let pick = plain_read_line(prompt).await?.trim().to_string();
// Blank line between the typed selection and the response below.
println!();
if let Some(idx) = pick.parse::<usize>().ok().and_then(|n| n.checked_sub(1)) {
if let Some(m) = shown.get(idx) {
state.config.model_override = Some(m.clone());
Expand Down
10 changes: 7 additions & 3 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,20 @@ fn read_plain_outcome(
continue;
}
if let Some(outcome) = control_key_outcome(code, modifiers) {
// See the Enter branch: `\r\n`, not `\n`, while raw mode is on.
redraw(&mut out, &chars, cursor, sel, true)?;
writeln!(out)?;
write!(out, "\r\n")?;
out.flush()?;
return Ok(outcome);
}
match code {
KeyCode::Enter => {
// Clear any open menu, then drop to the next line.
// Clear any open menu, then drop to the next line. Raw mode
// is still active here, so a bare `\n` only line-feeds and
// leaves the cursor in the input's last column — `\r` returns
// it to column 0 so the caller's output isn't shifted right.
redraw(&mut out, &chars, cursor, sel, true)?;
writeln!(out)?;
write!(out, "\r\n")?;
out.flush()?;
return Ok(ReadLineOutcome::Line(chars.iter().collect()));
}
Expand Down