Skip to content

Commit a29dbb9

Browse files
committed
feat: make the hover state for reveal, sort, and hidden commands stable (#2657)
1 parent 7169e19 commit a29dbb9

File tree

16 files changed

+75
-74
lines changed

16 files changed

+75
-74
lines changed

cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":"0.2","language":"en","words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","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","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition"],"flagWords":[]}
1+
{"version":"0.2","language":"en","flagWords":[],"words":["Punct","KEYMAP","splitn","crossterm","YAZI","peekable","ratatui","syntect","pbpaste","pbcopy","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","indexmap","indexmap","unwatch","canonicalize","serde","fsevent","Ueberzug","iterm","wezterm","sixel","chafa","ueberzugpp","Konsole","Überzug","pkgs","pdftoppm","poppler","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","ZELLIJ","bitflags","bitflags","USERPROFILE","Neovim","vergen","gitcl","Renderable","preloaders","prec","Upserting","prio","Ghostty","Catmull","Lanczos","cmds","unyank","scrolloff","headsup","unsub","uzers","scopeguard","SPDLOG","globset","filetime","magick","magick","prefetcher","Prework","prefetchers","PREWORKERS","conds","translit","rxvt","Urxvt","realpath","realname","REPARSE","hardlink","hardlinking","nlink","nlink","linemodes","SIGSTOP","sevenzip","rsplitn","replacen","DECSET","DECRQM","repeek","cwds","tcsi","Hyprland","Wayfire","SWAYSOCK","btime","nsec","codegen","gethostname","fchmod","fdfind","Rustc","rustc","ffprobe","vframes","luma","obase","outln","errln","tmtheme","twox","cfgs","fstype","objc","rdev","runloop","exfat","rclone","DECRQSS","DECSCUSR","libvterm","Uninit","lockin","rposition","resvg"]}

yazi-boot/src/actions/debug.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ impl Actions {
9393
writeln!(s, " zoxide : {}", Self::process_output("zoxide", "--version"))?;
9494
#[rustfmt::skip]
9595
writeln!(s, " 7zz/7z : {} / {}", Self::process_output("7zz", "i"), Self::process_output("7z", "i"))?;
96+
writeln!(s, " resvg : {}", Self::process_output("resvg", "--version"))?;
9697
writeln!(s, " jq : {}", Self::process_output("jq", "--version"))?;
9798

9899
writeln!(s, "\nClipboard")?;

yazi-core/src/mgr/commands/hover.rs

Lines changed: 0 additions & 50 deletions
This file was deleted.

yazi-core/src/mgr/commands/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ yazi_macro::mod_flat!(
33
close
44
create
55
hardlink
6-
hover
76
link
87
open
98
paste

yazi-core/src/mgr/commands/refresh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ impl Mgr {
2121
self.watcher.trigger_dirs(&[self.current()]);
2222
}
2323

24-
self.watch(());
2524
self.peek(false);
25+
self.watch(());
2626
self.update_paged((), tasks);
2727

2828
tasks.prework_sorted(&self.current().files);

yazi-core/src/mgr/commands/update_files.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ impl Mgr {
3030
}
3131

3232
render!(self.yanked.catchup_revision(false));
33+
self.active_mut().apply_files_attrs();
34+
3335
if revision != self.current().files.revision {
34-
self.active_mut().apply_files_attrs();
35-
self.hover(None);
36+
self.active_mut().hover(None);
3637
self.peek(false);
38+
self.watch(());
3739
self.update_paged((), tasks);
3840
}
3941
}

yazi-core/src/tab/commands/arrow.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ impl Tab {
3636
}
3737
}
3838

39-
MgrProxy::hover(None, self.id);
39+
self.hover(None);
4040
MgrProxy::peek(false);
41+
MgrProxy::watch();
42+
4143
render!();
4244
}
4345
}

yazi-core/src/tab/commands/filter_do.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ impl Tab {
2727

2828
self.current.repos(hovered.as_ref());
2929
if self.hovered().map(|f| f.urn()) != hovered.as_ref().map(|u| u.as_urn()) {
30-
MgrProxy::hover(None, self.id);
30+
self.hover(None);
3131
MgrProxy::peek(false);
32+
MgrProxy::watch();
3233
}
3334

3435
render!();

yazi-core/src/tab/commands/hidden.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ impl Tab {
1515
self.apply_files_attrs();
1616

1717
if hovered.as_ref() != self.hovered().map(|f| &f.url) {
18-
MgrProxy::hover(hovered, self.id);
18+
self.hover(hovered);
1919
MgrProxy::peek(false);
20+
MgrProxy::watch();
2021
} else if self.hovered().is_some_and(|f| f.is_dir()) {
2122
MgrProxy::peek(true);
2223
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
use yazi_dds::Pubsub;
2+
use yazi_macro::render;
3+
use yazi_shared::{event::CmdCow, url::{Url, Urn}};
4+
5+
use crate::tab::Tab;
6+
7+
struct Opt {
8+
url: Option<Url>,
9+
}
10+
11+
impl From<CmdCow> for Opt {
12+
fn from(mut c: CmdCow) -> Self { Self { url: c.take_first_url() } }
13+
}
14+
impl From<Option<Url>> for Opt {
15+
fn from(url: Option<Url>) -> Self { Self { url } }
16+
}
17+
18+
impl Tab {
19+
#[yazi_codegen::command]
20+
pub fn hover(&mut self, opt: Opt) {
21+
if let Some(u) = opt.url {
22+
self.hover_do(u);
23+
} else {
24+
self.current.arrow(0);
25+
}
26+
27+
// Publish through DDS
28+
Pubsub::pub_from_hover(self.id, self.hovered().map(|h| &h.url));
29+
}
30+
31+
fn hover_do(&mut self, url: Url) {
32+
// Hover on the file
33+
if let Ok(p) = url.strip_prefix(self.cwd()) {
34+
render!(self.current.hover(Urn::new(p)));
35+
}
36+
37+
// Turn on tracing
38+
if self.hovered().is_some_and(|h| h.url == url) {
39+
// `hover(Some)` occurs after user actions, such as create, rename, reveal, etc.
40+
// At this point, it's intuitive to track the location of the file regardless.
41+
self.current.trace = Some(url.urn_owned());
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)