diff options
Diffstat (limited to 'azalea-brigadier/src/exceptions/command_syntax_exception.rs')
| -rw-r--r-- | azalea-brigadier/src/exceptions/command_syntax_exception.rs | 27 |
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 } |
