mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-31 03:51:14 -03:00
Idiomatic type for reader_readline nchars argument
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
use crate::wutil::encoding::zero_mbstate;
|
||||
use crate::wutil::perror;
|
||||
use libc::SEEK_CUR;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::os::fd::RawFd;
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
@@ -244,7 +245,7 @@ fn read_interactive(
|
||||
|
||||
let mline = {
|
||||
let _interactive = parser.push_scope(|s| s.is_interactive = true);
|
||||
reader_readline(parser, nchars)
|
||||
reader_readline(parser, NonZeroUsize::try_from(nchars).ok())
|
||||
};
|
||||
terminal_protocols_disable_ifn();
|
||||
if let Some(line) = mline {
|
||||
|
||||
@@ -1060,12 +1060,11 @@ pub fn reader_reading_interrupted(data: &mut ReaderData) -> i32 {
|
||||
}
|
||||
|
||||
/// Read one line of input. Before calling this function, reader_push() must have been called in
|
||||
/// order to set up a valid reader environment. If nchars > 0, return after reading that many
|
||||
/// order to set up a valid reader environment. If nchars is given, return after reading that many
|
||||
/// characters even if a full line has not yet been read. Note: the returned value may be longer
|
||||
/// than nchars if a single keypress resulted in multiple characters being inserted into the
|
||||
/// commandline.
|
||||
pub fn reader_readline(parser: &Parser, nchars: usize) -> Option<WString> {
|
||||
let nchars = NonZeroUsize::try_from(nchars).ok();
|
||||
pub fn reader_readline(parser: &Parser, nchars: Option<NonZeroUsize>) -> Option<WString> {
|
||||
let data = current_data().unwrap();
|
||||
let mut reader = Reader { parser, data };
|
||||
reader.readline(nchars)
|
||||
|
||||
Reference in New Issue
Block a user