From bbd7bcf4aac6a261c2cb2c09bb6b396d76c4cc10 Mon Sep 17 00:00:00 2001 From: Thomas Frans Date: Sat, 3 Jun 2023 16:04:02 +0200 Subject: [PATCH] fix: command line multi-byte prefix panic Don't index into the command line command as the prefix can be altered by the user and therefore be a multi-byte unicode character. --- src/ui/layout.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ui/layout.rs b/src/ui/layout.rs index 5aeeed7..3b10c44 100644 --- a/src/ui/layout.rs +++ b/src/ui/layout.rs @@ -58,7 +58,9 @@ impl Layout { s.on_layout(|_, mut layout| layout.clear_cmdline()); // 3. Get the actual command without the prefix (like `:` or `/`)... - let cmd_without_prefix = &cmd[1..]; + let mut command_characters = cmd.chars(); + command_characters.next(); + let cmd_without_prefix = command_characters.as_str(); if cmd.strip_prefix('/').is_some() { // 4. If it is a search command...