Skip to content

Commit af9168d

Browse files
committed
Reformat
1 parent ed94caa commit af9168d

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/term.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ impl Term {
255255
buffer.extend_from_slice(prompt.as_bytes());
256256
Ok(())
257257
}
258-
None => {
259-
self.write_through(format!("{}\n{}", s, prompt.as_str()).as_bytes())
260-
}
258+
None => self.write_through(format!("{}\n{}", s, prompt.as_str()).as_bytes()),
261259
}
262260
}
263261

@@ -315,7 +313,7 @@ impl Term {
315313
}
316314

317315
/// Read one line of input with initial text.
318-
///
316+
///
319317
/// This method blocks until no other thread is waiting for this read_line
320318
/// before reading a line from the terminal.
321319
/// This does not include the trailing newline. If the terminal is not
@@ -331,31 +329,31 @@ impl Term {
331329
self.write_str(initial)?;
332330

333331
fn read_line_internal(slf: &Term, initial: &str) -> io::Result<String> {
334-
let prefix_len = initial.len();
332+
let prefix_len = initial.len();
335333

336-
let mut chars: Vec<char> = initial.chars().collect();
334+
let mut chars: Vec<char> = initial.chars().collect();
337335

338-
loop {
339-
match slf.read_key()? {
340-
Key::Backspace => {
341-
if prefix_len < chars.len() && chars.pop().is_some() {
342-
slf.clear_chars(1)?;
343-
}
344-
slf.flush()?;
345-
}
346-
Key::Char(chr) => {
347-
chars.push(chr);
348-
let mut bytes_char = [0; 4];
349-
chr.encode_utf8(&mut bytes_char);
350-
slf.write_str(chr.encode_utf8(&mut bytes_char))?;
351-
slf.flush()?;
352-
}
353-
Key::Enter => {
354-
slf.write_through(format!("\n{}", initial).as_bytes())?;
355-
break;
336+
loop {
337+
match slf.read_key()? {
338+
Key::Backspace => {
339+
if prefix_len < chars.len() && chars.pop().is_some() {
340+
slf.clear_chars(1)?;
356341
}
357-
_ => (),
342+
slf.flush()?;
358343
}
344+
Key::Char(chr) => {
345+
chars.push(chr);
346+
let mut bytes_char = [0; 4];
347+
chr.encode_utf8(&mut bytes_char);
348+
slf.write_str(chr.encode_utf8(&mut bytes_char))?;
349+
slf.flush()?;
350+
}
351+
Key::Enter => {
352+
slf.write_through(format!("\n{}", initial).as_bytes())?;
353+
break;
354+
}
355+
_ => (),
356+
}
359357
}
360358
Ok(chars.iter().skip(prefix_len).collect::<String>())
361359
}

0 commit comments

Comments
 (0)