~taiite/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH senpai] ui: improve buffer number detection

Details
Message ID
<0101017dbc028379-489151fb-58a6-4f34-a541-adc4babc7635-000000@us-west-2.amazonses.com>
DKIM signature
missing
Download raw message
Patch: +9 -1
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
Details
Message ID
<35609ba9-16ab-6555-9fbb-0861688f3834@hirtz.pm>
In-Reply-To
<0101017dbc028379-489151fb-58a6-4f34-a541-adc4babc7635-000000@us-west-2.amazonses.com> (view parent)
DKIM signature
missing
Download raw message
On 15/12/2021 03:53, Kalyan Sriram wrote:
> 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".

I see, thanks for the patch.  While I don't use neither buffer numbers 
nor /buffer myself, I expect typing "/b <number>" be the common 
practice, and this patch breaks it?  What do you think?
Details
Message ID
<0101017dbecfdfb1-febc4289-c19c-4c4a-acb0-f00a5ce682bb-000000@us-west-2.amazonses.com>
In-Reply-To
<35609ba9-16ab-6555-9fbb-0861688f3834@hirtz.pm> (view parent)
DKIM signature
missing
Download raw message
On Wed Dec 15, 2021 at 6:32 AM PST, Hubert Hirtz wrote:
> On 15/12/2021 03:53, Kalyan Sriram wrote:
> > 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".
>
> I see, thanks for the patch. While I don't use neither buffer numbers
> nor /buffer myself, I expect typing "/b <number>" be the common
> practice, and this patch breaks it? What do you think?

Yes, typing /b is the common practice but unfortunately doesn't
currently work since the "BAN" command was introduced. /b brings up the
numbers, but once the user presses enter, the command complains saying
"b" is ambigious. Hence I thought this would be the least intrusive way
to fix that. What do you think? Is there a better way to address this?

Kalyan
Reply to thread Export thread (mbox)