diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e975696b7..18fb0be33e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added reworked dungeon: Haniwa Catacombs - Added dungeon: Terracotta Ruins - Sand and crystal cave biome +- In commands that reference assets you can now use `#name` and press tab to cycle through assets with that name. ### Changed diff --git a/voxygen/src/cmd.rs b/voxygen/src/cmd.rs index f1ff2a4cba..e05013d49d 100644 --- a/voxygen/src/cmd.rs +++ b/voxygen/src/cmd.rs @@ -597,15 +597,23 @@ impl TabComplete for ArgumentSpec { .map(|c| c.to_string()) .collect(), ArgumentSpec::AssetPath(_, prefix, paths, _) => { - let part_with_prefix = prefix.to_string() + part; - 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() + if let Some(part_stripped) = part.strip_prefix('#') { + paths + .iter() + .filter(|string| string.contains(part_stripped)) + .filter_map(|c| Some(c.strip_prefix(prefix)?.to_string())) + .collect() + } else { + let part_with_prefix = prefix.to_string() + part; + 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"] .iter()