mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 14:51:03 +00:00
fix: respect URL covariance when updating mimetypes (#3079)
This commit is contained in:
parent
a41931275c
commit
fe9ce240b5
14 changed files with 94 additions and 113 deletions
102
Cargo.lock
generated
102
Cargo.lock
generated
|
|
@ -136,9 +136,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.4.1"
|
||||
version = "1.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
|
||||
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
|
||||
|
||||
[[package]]
|
||||
name = "arc-swap"
|
||||
|
|
@ -194,9 +194,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "avif-serialize"
|
||||
version = "0.8.5"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2ea8ef51aced2b9191c08197f55450d830876d9933f8f48a429b354f1d496b42"
|
||||
checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
|
@ -255,9 +255,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.1"
|
||||
version = "2.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
|
||||
checksum = "6a65b545ab31d687cff52899d4890855fec459eb6afe0da6417b8a18da87aa29"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
|
@ -280,15 +280,6 @@ dependencies = [
|
|||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bstr"
|
||||
version = "1.12.0"
|
||||
|
|
@ -352,9 +343,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.32"
|
||||
version = "1.2.33"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2352e5597e9c544d5e6d9c95190d5d27738ade584fa8db0a16e130e5c2b5296e"
|
||||
checksum = "3ee0f8803222ba5a7e2777dd72ca451868909b1ac410621b676adf07280e9b5f"
|
||||
dependencies = [
|
||||
"jobserver",
|
||||
"libc",
|
||||
|
|
@ -578,7 +569,7 @@ version = "0.28.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"crossterm_winapi",
|
||||
"mio",
|
||||
"parking_lot",
|
||||
|
|
@ -594,7 +585,7 @@ version = "0.29.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"crossterm_winapi",
|
||||
"derive_more",
|
||||
"document-features",
|
||||
|
|
@ -1178,7 +1169,7 @@ version = "0.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"inotify-sys",
|
||||
"libc",
|
||||
]
|
||||
|
|
@ -1222,7 +1213,7 @@ version = "0.7.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
|
|
@ -1340,7 +1331,7 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
|
|
@ -1562,7 +1553,7 @@ version = "8.2.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"fsevent-sys",
|
||||
"inotify",
|
||||
"kqueue",
|
||||
|
|
@ -1664,19 +1655,12 @@ dependencies = [
|
|||
"malloc_buf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc-sys"
|
||||
version = "0.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.5.2"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"
|
||||
checksum = "561f357ba7f3a2a61563a186a163d0a3a5247e1089524a3981d49adb775078bc"
|
||||
dependencies = [
|
||||
"objc-sys",
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
|
|
@ -1688,13 +1672,11 @@ checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
|
|||
|
||||
[[package]]
|
||||
name = "objc2-foundation"
|
||||
version = "0.2.2"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
|
||||
checksum = "900831247d2fe1a09a683278e5384cfb8c80c79fe6b166f9d14bfdde0ea1b03c"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"block2",
|
||||
"libc",
|
||||
"bitflags 2.9.2",
|
||||
"objc2",
|
||||
]
|
||||
|
||||
|
|
@ -1725,7 +1707,7 @@ version = "6.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "336b9c63443aceef14bea841b899035ae3abe89b7c486aaf4c5bd8aafedac3f0"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"onig_sys",
|
||||
|
|
@ -1929,9 +1911,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.97"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d61789d7719defeb74ea5fe81f2fdfdbd28a803847077cecce2ff14e1472f6f1"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
@ -2080,7 +2062,7 @@ version = "0.29.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"cassowary",
|
||||
"compact_str",
|
||||
"crossterm 0.28.1",
|
||||
|
|
@ -2160,7 +2142,7 @@ version = "0.5.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2171,7 +2153,7 @@ checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
|
|||
dependencies = [
|
||||
"getrandom 0.2.16",
|
||||
"libredox",
|
||||
"thiserror 2.0.14",
|
||||
"thiserror 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2251,7 +2233,7 @@ version = "0.38.44"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.4.15",
|
||||
|
|
@ -2264,7 +2246,7 @@ version = "1.0.8"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys 0.9.4",
|
||||
|
|
@ -2515,9 +2497,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.105"
|
||||
version = "2.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7bc3fcb250e53458e712715cf74285c1f889686520d79294a9ef3bd7aa1fc619"
|
||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -2592,11 +2574,11 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.14"
|
||||
version = "2.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e"
|
||||
checksum = "80d76d3f064b981389ecb4b6b7f45a0bf9fdac1d5b9204c7bd6714fecc302850"
|
||||
dependencies = [
|
||||
"thiserror-impl 2.0.14",
|
||||
"thiserror-impl 2.0.15",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2612,9 +2594,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.14"
|
||||
version = "2.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227"
|
||||
checksum = "44d29feb33e986b6ea906bd9c3559a856983f92371b3eaa5e83782a351623de0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
|
@ -2886,9 +2868,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "trash"
|
||||
version = "5.2.2"
|
||||
version = "5.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22746c6b0c6d85d60a8f0d858f7057dfdf11297c132679f452ec908fba42b871"
|
||||
checksum = "65a334451012017a39758aa85a30827c13ac684245bf6b08249483c063f64ff3"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"libc",
|
||||
|
|
@ -3464,7 +3446,7 @@ version = "0.39.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -3484,7 +3466,7 @@ dependencies = [
|
|||
"crossterm 0.29.0",
|
||||
"foldhash",
|
||||
"futures",
|
||||
"indexmap",
|
||||
"hashbrown",
|
||||
"libc",
|
||||
"mlua",
|
||||
"paste",
|
||||
|
|
@ -3535,7 +3517,6 @@ version = "25.6.11"
|
|||
dependencies = [
|
||||
"ansi-to-tui",
|
||||
"foldhash",
|
||||
"hashbrown",
|
||||
"mlua",
|
||||
"paste",
|
||||
"ratatui",
|
||||
|
|
@ -3612,7 +3593,7 @@ name = "yazi-config"
|
|||
version = "25.6.11"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"crossterm 0.29.0",
|
||||
"dirs",
|
||||
"globset",
|
||||
|
|
@ -3742,7 +3723,7 @@ version = "25.6.11"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"arc-swap",
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"core-foundation-sys",
|
||||
"dirs",
|
||||
"foldhash",
|
||||
|
|
@ -3775,7 +3756,7 @@ name = "yazi-parser"
|
|||
version = "25.6.11"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bitflags 2.9.1",
|
||||
"bitflags 2.9.2",
|
||||
"crossterm 0.29.0",
|
||||
"hashbrown",
|
||||
"mlua",
|
||||
|
|
@ -3796,7 +3777,6 @@ dependencies = [
|
|||
"anyhow",
|
||||
"crossterm 0.29.0",
|
||||
"futures",
|
||||
"globset",
|
||||
"libc",
|
||||
"mlua",
|
||||
"parking_lot",
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ lto = false
|
|||
ansi-to-tui = "7.0.0"
|
||||
anyhow = "1.0.99"
|
||||
base64 = "0.22.1"
|
||||
bitflags = { version = "2.9.1", features = [ "serde" ] }
|
||||
bitflags = { version = "2.9.2", features = [ "serde" ] }
|
||||
clap = { version = "4.5.45", features = [ "derive" ] }
|
||||
core-foundation-sys = "0.8.7"
|
||||
crossterm = { version = "0.29.0", features = [ "event-stream" ] }
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"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","foldhash","tilded","futs","chdir","hashbrown"],"flagWords":[],"version":"0.2","language":"en"}
|
||||
{"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","foldhash","tilded","futs","chdir","hashbrown","JEMALLOC","RUSTFLAGS"]}
|
||||
|
|
@ -32,7 +32,7 @@ anyhow = { workspace = true }
|
|||
crossterm = { workspace = true }
|
||||
foldhash = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
indexmap = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
mlua = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
scopeguard = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::Result;
|
||||
use hashbrown::HashMap;
|
||||
use yazi_core::mgr::LINKED;
|
||||
use yazi_macro::{act, render, succ};
|
||||
use yazi_parser::mgr::UpdateMimesOpt;
|
||||
use yazi_shared::event::Data;
|
||||
use yazi_shared::{event::Data, url::UrlCov};
|
||||
|
||||
use crate::{Actor, Ctx};
|
||||
|
||||
|
|
@ -24,9 +23,9 @@ impl Actor for UpdateMimes {
|
|||
.filter(|(url, mime)| cx.mgr.mimetype.by_url(url) != Some(mime))
|
||||
.fold(HashMap::new(), |mut map, (u, m)| {
|
||||
for u in linked.from_file(u.as_url()) {
|
||||
map.insert(u, m.to_string());
|
||||
map.insert(u.into(), m.to_string());
|
||||
}
|
||||
map.insert(u.into_owned(), m.into_owned());
|
||||
map.insert(u.into(), m.into_owned());
|
||||
map
|
||||
});
|
||||
|
||||
|
|
@ -39,11 +38,11 @@ impl Actor for UpdateMimes {
|
|||
.current()
|
||||
.paginate(cx.current().page)
|
||||
.iter()
|
||||
.filter(|&f| updates.contains_key(&f.url))
|
||||
.filter(|&f| updates.contains_key(&UrlCov::new(&f.url)))
|
||||
.cloned()
|
||||
.collect();
|
||||
|
||||
let repeek = cx.hovered().is_some_and(|f| updates.contains_key(&f.url));
|
||||
let repeek = cx.hovered().is_some_and(|f| updates.contains_key(&UrlCov::new(&f.url)));
|
||||
cx.mgr.mimetype.extend(updates);
|
||||
|
||||
if repeek {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ yazi-shared = { path = "../yazi-shared", version = "25.6.11" }
|
|||
# External dependencies
|
||||
ansi-to-tui = { workspace = true }
|
||||
foldhash = { workspace = true }
|
||||
hashbrown = { workspace = true }
|
||||
mlua = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
ratatui = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
|
||||
let profile = if target_os == "windows" { &["--profile", "release-windows"][..] } else { &[] };
|
||||
let mut child = Command::new(env::var_os("CARGO").unwrap())
|
||||
.args(&["install", "--force", "--locked"])
|
||||
.args(["install", "--force", "--locked"])
|
||||
.args(profile)
|
||||
.args(crates)
|
||||
.stdout(Stdio::piped())
|
||||
|
|
|
|||
|
|
@ -13,5 +13,5 @@ proc-macro = true
|
|||
|
||||
[dependencies]
|
||||
# External dependencies
|
||||
syn = { version = "2.0.105", features = [ "full" ] }
|
||||
syn = { version = "2.0.106", features = [ "full" ] }
|
||||
quote = "1.0.40"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::borrow::Cow;
|
|||
|
||||
use hashbrown::HashMap;
|
||||
use yazi_fs::File;
|
||||
use yazi_shared::{MIME_DIR, SStr, url::{Url, UrlBuf, UrlBufCov, UrlCov}};
|
||||
use yazi_shared::{MIME_DIR, SStr, url::{Url, UrlBufCov, UrlCov}};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Mimetype(HashMap<UrlBufCov, String>);
|
||||
|
|
@ -34,7 +34,7 @@ impl Mimetype {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn extend(&mut self, iter: impl IntoIterator<Item = (UrlBuf, String)>) {
|
||||
self.0.extend(iter.into_iter().map(|(u, m)| (UrlBufCov(u), m)));
|
||||
pub fn extend(&mut self, iter: impl IntoIterator<Item = (UrlBufCov, String)>) {
|
||||
self.0.extend(iter);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,8 +164,8 @@ mod tests {
|
|||
fn test_insert_non_conflicting() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert!(s.add(&url("/a/b")));
|
||||
assert!(s.add(&url("/c/d")));
|
||||
assert!(s.add(url("/a/b")));
|
||||
assert!(s.add(url("/c/d")));
|
||||
assert_eq!(s.inner.len(), 2);
|
||||
}
|
||||
|
||||
|
|
@ -173,27 +173,27 @@ mod tests {
|
|||
fn test_insert_conflicting_parent() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert!(s.add(&url("/a")));
|
||||
assert!(!s.add(&url("/a/b")));
|
||||
assert!(s.add(url("/a")));
|
||||
assert!(!s.add(url("/a/b")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_insert_conflicting_child() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert!(s.add(&url("/a/b/c")));
|
||||
assert!(!s.add(&url("/a/b")));
|
||||
assert!(s.add(&url("/a/b/d")));
|
||||
assert!(s.add(url("/a/b/c")));
|
||||
assert!(!s.add(url("/a/b")));
|
||||
assert!(s.add(url("/a/b/d")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_remove() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert!(s.add(&url("/a/b")));
|
||||
assert!(!s.remove(&url("/a/c")));
|
||||
assert!(s.remove(&url("/a/b")));
|
||||
assert!(!s.remove(&url("/a/b")));
|
||||
assert!(s.add(url("/a/b")));
|
||||
assert!(!s.remove(url("/a/c")));
|
||||
assert!(s.remove(url("/a/b")));
|
||||
assert!(!s.remove(url("/a/b")));
|
||||
assert!(s.inner.is_empty());
|
||||
assert!(s.parents.is_empty());
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ mod tests {
|
|||
|
||||
assert_eq!(
|
||||
3,
|
||||
s.add_same([&url("/parent/child1"), &url("/parent/child2"), &url("/parent/child3")])
|
||||
s.add_same([url("/parent/child1"), url("/parent/child2"), url("/parent/child3")])
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -212,62 +212,62 @@ mod tests {
|
|||
fn insert_many_with_existing_parent_fails() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/parent"));
|
||||
assert_eq!(0, s.add_same([&url("/parent/child1"), &url("/parent/child2")]));
|
||||
s.add(url("/parent"));
|
||||
assert_eq!(0, s.add_same([url("/parent/child1"), url("/parent/child2")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_with_existing_child_fails() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/parent/child1"));
|
||||
assert_eq!(2, s.add_same([&url("/parent/child1"), &url("/parent/child2")]));
|
||||
s.add(url("/parent/child1"));
|
||||
assert_eq!(2, s.add_same([url("/parent/child1"), url("/parent/child2")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_empty_urls_list() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert_eq!(0, s.add_same([] as [&Url; 0]));
|
||||
assert_eq!(0, s.add_same([] as [Url; 0]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_with_parent_as_child_of_another_url() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/parent/child"));
|
||||
assert_eq!(0, s.add_same([&url("/parent/child/child1"), &url("/parent/child/child2")]));
|
||||
s.add(url("/parent/child"));
|
||||
assert_eq!(0, s.add_same([url("/parent/child/child1"), url("/parent/child/child2")]));
|
||||
}
|
||||
#[test]
|
||||
fn insert_many_with_direct_parent_fails() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/a"));
|
||||
assert_eq!(0, s.add_same([&url("/a/b")]));
|
||||
s.add(url("/a"));
|
||||
assert_eq!(0, s.add_same([url("/a/b")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_with_nested_child_fails() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/a/b"));
|
||||
assert_eq!(0, s.add_same([&url("/a")]));
|
||||
assert_eq!(1, s.add_same([&url("/b"), &url("/a")]));
|
||||
s.add(url("/a/b"));
|
||||
assert_eq!(0, s.add_same([url("/a")]));
|
||||
assert_eq!(1, s.add_same([url("/b"), url("/a")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_sibling_directories_success() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
assert_eq!(2, s.add_same([&url("/a/b"), &url("/a/c")]));
|
||||
assert_eq!(2, s.add_same([url("/a/b"), url("/a/c")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_many_with_grandchild_fails() {
|
||||
let mut s = Selected::default();
|
||||
|
||||
s.add(&url("/a/b"));
|
||||
assert_eq!(0, s.add_same([&url("/a/b/c")]));
|
||||
s.add(url("/a/b"));
|
||||
assert_eq!(0, s.add_same([url("/a/b/c")]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ pub fn url_relative_to_impl<'a>(from: UrlCow<'a>, to: UrlCow<'a>) -> Result<UrlC
|
|||
|
||||
if from.is_absolute() != to.is_absolute() {
|
||||
return if to.is_absolute() {
|
||||
Ok(to.into())
|
||||
Ok(to)
|
||||
} else {
|
||||
bail!("Urls must be both absolute or both relative: {from:?} and {to:?}");
|
||||
};
|
||||
|
|
@ -92,7 +92,7 @@ pub fn url_relative_to_impl<'a>(from: UrlCow<'a>, to: UrlCow<'a>) -> Result<UrlC
|
|||
(Some(RootDir), Some(RootDir)) => {}
|
||||
(Some(Prefix(a)), Some(Prefix(b))) if a == b => {}
|
||||
(Some(Scheme(_) | Prefix(_) | RootDir), _) | (_, Some(Scheme(_) | Prefix(_) | RootDir)) => {
|
||||
return Ok(to.into());
|
||||
return Ok(to);
|
||||
}
|
||||
(None, None) => break (None, None),
|
||||
(a, b) if a != b => break (a, b),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ yazi-widgets = { path = "../yazi-widgets", version = "25.6.11" }
|
|||
anyhow = { workspace = true }
|
||||
crossterm = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
globset = { workspace = true }
|
||||
mlua = { workspace = true }
|
||||
parking_lot = { workspace = true }
|
||||
paste = { workspace = true }
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ tracing = { workspace = true }
|
|||
libc = { workspace = true }
|
||||
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
trash = "5.2.2"
|
||||
trash = "5.2.3"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::{hash::{Hash, Hasher}, ops::Deref};
|
|||
use hashbrown::Equivalent;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::url::{Url, UrlBuf};
|
||||
use crate::url::{Url, UrlBuf, UrlCow};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct UrlCov<'a>(Url<'a>);
|
||||
|
|
@ -54,14 +54,18 @@ impl From<UrlBuf> for UrlBufCov {
|
|||
fn from(value: UrlBuf) -> Self { Self(value) }
|
||||
}
|
||||
|
||||
impl From<&UrlCov<'_>> for UrlBufCov {
|
||||
fn from(value: &UrlCov<'_>) -> Self { Self(UrlBuf::from(&value.0)) }
|
||||
}
|
||||
|
||||
impl From<UrlBufCov> for UrlBuf {
|
||||
fn from(value: UrlBufCov) -> Self { value.0 }
|
||||
}
|
||||
|
||||
impl From<UrlCow<'_>> for UrlBufCov {
|
||||
fn from(value: UrlCow<'_>) -> Self { Self(value.into_owned()) }
|
||||
}
|
||||
|
||||
impl From<&UrlCov<'_>> for UrlBufCov {
|
||||
fn from(value: &UrlCov<'_>) -> Self { Self(UrlBuf::from(&value.0)) }
|
||||
}
|
||||
|
||||
impl<'a> From<&'a UrlBufCov> for Url<'a> {
|
||||
fn from(value: &'a UrlBufCov) -> Self { value.0.as_url() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue