From bae53f44bbdb747b044fc2a687641fdfed665966 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sat, 12 Oct 2024 21:24:59 +0900 Subject: [PATCH] use strings.CutSuffix on parsing bang of command --- cmdline/parse.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmdline/parse.go b/cmdline/parse.go index ce59e0a..69dba53 100644 --- a/cmdline/parse.go +++ b/cmdline/parse.go @@ -25,9 +25,7 @@ func parse(cmdline []rune) (command, *event.Range, string, bool, string, error) for k < l && unicode.IsSpace(cmdline[k]) { k++ } - cmdName := string(cmdline[i:j]) - bang := strings.HasSuffix(cmdName, "!") - cmdName = strings.TrimSuffix(cmdName, "!") + cmdName, bang := strings.CutSuffix(string(cmdline[i:j]), "!") for _, cmd := range commands { if len(cmdName) == 0 || cmdName[0] != cmd.name[0] { continue