mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Added substring search for asset path autocomplete
This commit is contained in:
parent
646c1ea4ba
commit
d9c9a671ed
@ -597,15 +597,23 @@ impl TabComplete for ArgumentSpec {
|
|||||||
.map(|c| c.to_string())
|
.map(|c| c.to_string())
|
||||||
.collect(),
|
.collect(),
|
||||||
ArgumentSpec::AssetPath(_, prefix, paths, _) => {
|
ArgumentSpec::AssetPath(_, prefix, paths, _) => {
|
||||||
let part_with_prefix = prefix.to_string() + part;
|
if let Some(part_stripped) = part.strip_prefix('#') {
|
||||||
let depth = part_with_prefix.split('.').count();
|
paths
|
||||||
paths
|
.iter()
|
||||||
.iter()
|
.filter(|string| string.contains(part_stripped))
|
||||||
.map(|path| path.as_str().split('.').take(depth).join("."))
|
.filter_map(|c| Some(c.strip_prefix(prefix)?.to_string()))
|
||||||
.dedup()
|
.collect()
|
||||||
.filter(|string| string.starts_with(&part_with_prefix))
|
} else {
|
||||||
.filter_map(|c| Some(c.strip_prefix(prefix)?.to_string()))
|
let part_with_prefix = prefix.to_string() + part;
|
||||||
.collect()
|
let depth = part_with_prefix.split('.').count();
|
||||||
|
paths
|
||||||
|
.iter()
|
||||||
|
.map(|path| path.as_str().split('.').take(depth).join("."))
|
||||||
|
.dedup()
|
||||||
|
.filter(|string| string.starts_with(&part_with_prefix))
|
||||||
|
.filter_map(|c| Some(c.strip_prefix(prefix)?.to_string()))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
ArgumentSpec::Boolean(_, part, _) => ["true", "false"]
|
ArgumentSpec::Boolean(_, part, _) => ["true", "false"]
|
||||||
.iter()
|
.iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user