Many people use “/b xxx” to switch between buffers. In senpai, you can't
currently do this, because “/b” is ambiguous between “/buffer” and
“/ban”, so you have to at least type “/bu”. I've added a special case
for “/b” which directly treats it as “/buffer”.
Signed-off-by: Vlad-Stefan Harbuz <vlad@vladh.net>
---
commands.go | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/commands.go b/commands.go
index c146ac2..cf0e29d 100644
--- a/commands.go
+++ b/commands.go
@@ -803,15 +803,20 @@ func (app *App) handleInput(buffer, content string) error {
var chosenCMDName string
var found bool
- for key := range commands {
- if !strings.HasPrefix(key, cmdName) {
- continue
- }
- if found {
- return fmt.Errorf("ambiguous command %q (could mean %v or %v)", cmdName, chosenCMDName, key)
- }
- chosenCMDName = key
+ if cmdName == "B" {
+ chosenCMDName = "BUFFER"
found = true
+ } else {
+ for key := range commands {
+ if !strings.HasPrefix(key, cmdName) {
+ continue
+ }
+ if found {
+ return fmt.Errorf("ambiguous command %q (could mean %v or %v)", cmdName, chosenCMDName, key)
+ }
+ chosenCMDName = key
+ found = true
+ }
}
if !found {
return fmt.Errorf("command %q doesn't exist", cmdName)
--
2.42.0