aboutsummaryrefslogtreecommitdiff
path: root/azalea-brigadier/src/exceptions/command_syntax_exception.rs
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-05-28 15:46:58 -0800
committermat <git@matdoes.dev>2025-05-28 14:47:18 -0900
commitda73b4316de4b26322c53f14222c7751a0be55a1 (patch)
treef3a8b656936d92032ca34800fcb64b648dd6bada /azalea-brigadier/src/exceptions/command_syntax_exception.rs
parent3d340f585a320d1d6553756e6ed85d0bd88af3b2 (diff)
downloadazalea-drasl-da73b4316de4b26322c53f14222c7751a0be55a1.tar.xz
add support for custom suggestions in azalea-brigadier and cleanup a bit
Diffstat (limited to 'azalea-brigadier/src/exceptions/command_syntax_exception.rs')
-rw-r--r--azalea-brigadier/src/exceptions/command_syntax_exception.rs27
1 files changed, 13 insertions, 14 deletions
diff --git a/azalea-brigadier/src/exceptions/command_syntax_exception.rs b/azalea-brigadier/src/exceptions/command_syntax_exception.rs
index 657649b0..c9b8134f 100644
--- a/azalea-brigadier/src/exceptions/command_syntax_exception.rs
+++ b/azalea-brigadier/src/exceptions/command_syntax_exception.rs
@@ -54,23 +54,22 @@ impl CommandSyntaxException {
}
pub fn context(&self) -> Option<String> {
- if let Some(input) = &self.input {
- if let Some(cursor) = self.cursor {
- let mut builder = String::new();
- let cursor = cmp::min(input.len(), cursor);
+ if let Some(input) = &self.input
+ && let Some(cursor) = self.cursor
+ {
+ let mut builder = String::new();
+ let cursor = cmp::min(input.len(), cursor);
- if cursor > CONTEXT_AMOUNT {
- builder.push_str("...");
- }
+ if cursor > CONTEXT_AMOUNT {
+ builder.push_str("...");
+ }
- builder.push_str(
- &input
- [(cmp::max(0, cursor as isize - CONTEXT_AMOUNT as isize) as usize)..cursor],
- );
- builder.push_str("<--[HERE]");
+ builder.push_str(
+ &input[(cmp::max(0, cursor as isize - CONTEXT_AMOUNT as isize) as usize)..cursor],
+ );
+ builder.push_str("<--[HERE]");
- return Some(builder);
- }
+ return Some(builder);
}
None
}