diff --git a/src/completion.rs b/src/completion.rs index b590b1483..c3df19a6a 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -334,21 +334,27 @@ fn filename_complete( if let Ok(read_dir) = dir.read_dir() { let file_name = normalize(file_name); for entry in read_dir.flatten() { - match entry.file_name().to_str() { Some(s) => { - let ns = normalize(s); - if ns.starts_with(file_name.as_ref()) { - match fs::metadata(entry.path()) { Ok(metadata) => { - let mut path = String::from(dir_name) + s; - if metadata.is_dir() { - path.push(sep); - } - entries.push(Pair { - display: String::from(s), - replacement: escape(path, esc_char, is_break_char, quote), - }); - } _ => {}} // else ignore PermissionDenied + match entry.file_name().to_str() { + Some(s) => { + let ns = normalize(s); + if ns.starts_with(file_name.as_ref()) { + match fs::metadata(entry.path()) { + Ok(metadata) => { + let mut path = String::from(dir_name) + s; + if metadata.is_dir() { + path.push(sep); + } + entries.push(Pair { + display: String::from(s), + replacement: escape(path, esc_char, is_break_char, quote), + }); + } + _ => {} + } // else ignore PermissionDenied + } } - } _ => {}} + _ => {} + } } } entries diff --git a/src/history.rs b/src/history.rs index ca871e042..b4c0bfd3a 100644 --- a/src/history.rs +++ b/src/history.rs @@ -229,25 +229,31 @@ impl MemHistory { .skip(self.len() - 1 - start) .enumerate() { - match test(entry) { Some(cursor) => { - return Some(SearchResult { - idx: start - idx, - entry: Cow::Borrowed(entry), - pos: cursor, - }); - } _ => {}} + match test(entry) { + Some(cursor) => { + return Some(SearchResult { + idx: start - idx, + entry: Cow::Borrowed(entry), + pos: cursor, + }); + } + _ => {} + } } None } SearchDirection::Forward => { for (idx, entry) in self.entries.iter().skip(start).enumerate() { - match test(entry) { Some(cursor) => { - return Some(SearchResult { - idx: idx + start, - entry: Cow::Borrowed(entry), - pos: cursor, - }); - } _ => {}} + match test(entry) { + Some(cursor) => { + return Some(SearchResult { + idx: idx + start, + entry: Cow::Borrowed(entry), + pos: cursor, + }); + } + _ => {} + } } None } diff --git a/src/lib.rs b/src/lib.rs index abf6fc11b..bd7945855 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -707,13 +707,16 @@ impl Editor { .term .create_reader(self.buffer.take(), &self.config, term_key_map); if self.term.is_output_tty() && self.config.check_cursor_position() { - match s.move_cursor_at_leftmost(&mut rdr) { Err(e) => { - if let ReadlineError::WindowResized = e { - s.out.update_size(); - } else { - return Err(e); + match s.move_cursor_at_leftmost(&mut rdr) { + Err(e) => { + if let ReadlineError::WindowResized = e { + s.out.update_size(); + } else { + return Err(e); + } } - } _ => {}} + _ => {} + } } s.refresh_line()?; diff --git a/src/tty/unix.rs b/src/tty/unix.rs index ae2336063..d25256379 100644 --- a/src/tty/unix.rs +++ b/src/tty/unix.rs @@ -757,14 +757,22 @@ impl PosixRawReader { } else if readfds.contains(tty_in) { // prefer user input over external print return self.next_key(single_esc_abort).map(Event::KeyPress); - } else { match self.pipe_reader { Some(ref pipe_reader) => { - let mut guard = pipe_reader.lock().unwrap(); - let mut buf = [0; 1]; - guard.0.read_exact(&mut buf)?; - match guard.1.try_recv() { Ok(msg) => { - return Ok(Event::ExternalPrint(msg)); - } _ => {}} - } _ => {}}} + } else { + match self.pipe_reader { + Some(ref pipe_reader) => { + let mut guard = pipe_reader.lock().unwrap(); + let mut buf = [0; 1]; + guard.0.read_exact(&mut buf)?; + match guard.1.try_recv() { + Ok(msg) => { + return Ok(Event::ExternalPrint(msg)); + } + _ => {} + } + } + _ => {} + } + } } } } @@ -1304,19 +1312,20 @@ impl Term for PosixTerminal { let (tty_in, is_in_a_tty, tty_out, is_out_a_tty, close_on_drop) = if behavior == Behavior::PreferTerm { let tty = OpenOptions::new().read(true).write(true).open("/dev/tty"); - match tty { Ok(tty) => { - let fd = tty.into_raw_fd(); - let is_a_tty = is_a_tty(fd); // TODO: useless ? - (fd, is_a_tty, fd, is_a_tty, true) - } _ => { - ( + match tty { + Ok(tty) => { + let fd = tty.into_raw_fd(); + let is_a_tty = is_a_tty(fd); // TODO: useless ? + (fd, is_a_tty, fd, is_a_tty, true) + } + _ => ( libc::STDIN_FILENO, is_a_tty(libc::STDIN_FILENO), libc::STDOUT_FILENO, is_a_tty(libc::STDOUT_FILENO), false, - ) - }} + ), + } } else { ( libc::STDIN_FILENO, @@ -1494,16 +1503,21 @@ impl super::ExternalPrinter for ExternalPrinter { // write directly to stdout/stderr while not in raw mode if !self.raw_mode.load(Ordering::SeqCst) { write_all(self.tty_out, msg.as_str())?; - } else { match self.writer.0.lock() { Ok(mut writer) => { - self.writer - .1 - .send(msg) - .map_err(|_| io::Error::from(ErrorKind::Other))?; // FIXME - writer.write_all(b"m")?; - writer.flush()?; - } _ => { - return Err(io::Error::from(ErrorKind::Other).into()); // FIXME - }}} + } else { + match self.writer.0.lock() { + Ok(mut writer) => { + self.writer + .1 + .send(msg) + .map_err(|_| io::Error::from(ErrorKind::Other))?; // FIXME + writer.write_all(b"m")?; + writer.flush()?; + } + _ => { + return Err(io::Error::from(ErrorKind::Other).into()); // FIXME + } + } + } Ok(()) } }