feat: prefer exact match when completion mode is prefix

This commit is contained in:
Himadri Bhattacharjee 2024-07-05 19:56:38 +05:30
parent 8707d14f95
commit bf3b6c7a84
No known key found for this signature in database

View File

@ -14,7 +14,7 @@ use std::path::{
is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP, MAIN_SEPARATOR_STR, is_separator, Component, Path, PathBuf, MAIN_SEPARATOR as SEP, MAIN_SEPARATOR_STR,
}; };
use super::SortBy; use super::{MatchAlgorithm, SortBy};
#[derive(Clone, Default)] #[derive(Clone, Default)]
pub struct PathBuiltFromString { pub struct PathBuiltFromString {
@ -76,6 +76,12 @@ fn complete_rec(
completions.push(built); completions.push(built);
} }
} }
if entry_name.eq(base)
&& matches!(options.match_algorithm, MatchAlgorithm::Prefix)
&& isdir
{
break;
}
} }
None => { None => {
completions.push(built); completions.push(built);