~taiite/public-inbox

senpai: ui: improve buffer number detection v1 PROPOSED

Kalyan Sriram: 1
 ui: improve buffer number detection

 1 files changed, 9 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~taiite/public-inbox/patches/27402/mbox | git am -3
Learn more about email & git

[PATCH senpai] ui: improve buffer number detection Export this patch

Improve show buffer numbers on "/buffer" command. Checks completion
against list of commands to avoid ambigious "/b" matching ("BUFFER" v.
"BAN"). Matches uppercase and mixed case i.e. "/BU" or "/bU".
---
 window.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/window.go b/window.go
index 82941a1..87e4be4 100644
--- a/window.go
+++ b/window.go
@@ -83,7 +83,15 @@ func (app *App) setBufferNumbers() {
		}
	}
	command := string(input[1:commandEnd])
	showBufferNumbers := len(command) != 0 && strings.HasPrefix("buffer", command)

	var completed []string
	uCommand := strings.ToUpper(command)
	for name, _ := range commands {
		if strings.HasPrefix(name, uCommand) {
			completed = append(completed, name)
		}
	}
	showBufferNumbers := len(command) != 0 && len(completed) == 1 && completed[0] == "BUFFER"
	app.win.ShowBufferNumbers(showBufferNumbers)
}

-- 
2.34.1