fix: completion won't closing when there are no candidates

This commit is contained in:
sxyazi 2023-11-05 00:37:43 +08:00
parent 539374fd14
commit 847c475d8c
No known key found for this signature in database
5 changed files with 12 additions and 11 deletions

View file

@ -1 +1 @@
{"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit"],"flagWords":[],"version":"0.2","language":"en"}
{"flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","unar","peekable","ratatui","syntect","pbpaste","pbcopy","ffmpegthumbnailer","oneshot","Posix","Lsar","XADDOS","zoxide","cands","Deque","precache","imageops","IFBLK","IFCHR","IFDIR","IFIFO","IFLNK","IFMT","IFSOCK","IRGRP","IROTH","IRUSR","ISGID","ISUID","ISVTX","IWGRP","IWOTH","IWUSR","IXGRP","IXOTH","IXUSR","libc","winsize","TIOCGWINSZ","xpixel","ypixel","ioerr","appender","Catppuccin","macchiato","gitmodules","Dotfiles","bashprofile","vimrc","flac","webp","exiftool","mediainfo","ripgrep","nvim","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp"," Überzug"," Überzug","Konsole","Alacritty","Überzug","pkgs","paru","unarchiver","pdftoppm","poppler","prebuild","singlefile","jpegopt","EXIF","rustfmt","mktemp","nanos","xclip","xsel","natord","Mintty","nixos","nixpkgs","SIGTSTP","SIGCONT","SIGCONT","mlua","nonstatic","userdata","metatable","natsort","backstack","luajit","Succ","Succ","cand","fileencoding","foldmethod","lightgreen","darkgray","lightred","lightyellow","lightcyan","nushell","msvc","aarch","linemode","sxyazi","rsplit","USERPROFILE"],"version":"0.2","language":"en"}

View file

@ -1,4 +1,4 @@
use std::ops::ControlFlow;
use std::{mem, ops::ControlFlow};
use yazi_config::keymap::Exec;
@ -46,17 +46,18 @@ impl Completion {
ControlFlow::Continue(v)
});
self.ticket = opt.ticket;
self.cands = match flow {
ControlFlow::Continue(v) => v,
ControlFlow::Break(v) => v,
};
self.ticket = opt.ticket;
if !self.cands.is_empty() {
self.offset = 0;
self.cursor = 0;
self.visible = true;
if self.cands.is_empty() {
return mem::replace(&mut self.visible, false);
}
self.offset = 0;
self.cursor = 0;
self.visible = true;
true
}
}

View file

@ -4,7 +4,7 @@ use crate::{emit, tab::Tab};
impl Tab {
pub fn hidden(&mut self, e: &Exec) -> bool {
self.conf.show_hidden = match e.args.get(0).map(|s| s.as_bytes()) {
self.conf.show_hidden = match e.args.first().map(|s| s.as_bytes()) {
Some(b"show") => true,
Some(b"hide") => false,
_ => !self.conf.show_hidden,

View file

@ -5,7 +5,7 @@ use crate::tab::Tab;
impl Tab {
pub fn linemode(&mut self, e: &Exec) -> bool {
self.conf.patch(|c| {
let Some(mode) = e.args.get(0) else {
let Some(mode) = e.args.first() else {
return;
};
if !mode.is_empty() && mode.len() <= 20 {

View file

@ -6,7 +6,7 @@ use crate::tab::Tab;
impl Tab {
pub fn sort(&mut self, e: &Exec) -> bool {
if let Some(by) = e.args.get(0) {
if let Some(by) = e.args.first() {
self.conf.sort_by = SortBy::from_str(by).unwrap_or_default();
}
self.conf.sort_sensitive = e.named.contains_key("sensitive");