mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: smart case completion in cd paths (#910)
Co-authored-by: sxyazi <sxyazi@gmail.com>
This commit is contained in:
parent
f442ae2adf
commit
64c5e85457
1 changed files with 3 additions and 1 deletions
|
|
@ -26,10 +26,12 @@ impl From<Cmd> for Opt {
|
||||||
|
|
||||||
impl Completion {
|
impl Completion {
|
||||||
fn match_candidates(word: &str, cache: &[String]) -> Vec<String> {
|
fn match_candidates(word: &str, cache: &[String]) -> Vec<String> {
|
||||||
|
let smart = word.chars().all(|c| c.is_lowercase());
|
||||||
|
|
||||||
let flow = cache.iter().try_fold(
|
let flow = cache.iter().try_fold(
|
||||||
(Vec::with_capacity(LIMIT), Vec::with_capacity(LIMIT)),
|
(Vec::with_capacity(LIMIT), Vec::with_capacity(LIMIT)),
|
||||||
|(mut prefixed, mut fuzzy), s| {
|
|(mut prefixed, mut fuzzy), s| {
|
||||||
if s.starts_with(word) {
|
if (smart && s.to_lowercase().starts_with(word)) || (!smart && s.starts_with(word)) {
|
||||||
if s != word {
|
if s != word {
|
||||||
prefixed.push(s);
|
prefixed.push(s);
|
||||||
if prefixed.len() >= LIMIT {
|
if prefixed.len() >= LIMIT {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue