From da73b4316de4b26322c53f14222c7751a0be55a1 Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 28 May 2025 15:46:58 -0800 Subject: add support for custom suggestions in azalea-brigadier and cleanup a bit --- .../src/exceptions/command_syntax_exception.rs | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'azalea-brigadier/src/exceptions/command_syntax_exception.rs') 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 { - 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 } -- cgit v1.2.3