~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

[PATCH senpai] ui: don't mark // in input as a command

Details
Message ID
<20210604210958.24830-1-yyp@disroot.org>
DKIM signature
pass
Download raw message
Patch: +5 -1
Prior to this, IsCommand was returning true for inputs starting with two
slashes and thus showing ">"-prompt.

This is a possible confusion (and unwanted behaviour) because the user
might think that they are writing a command but in fact, the message
would be sent verbatim (excluding first slash).
---
 ui/editor.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ui/editor.go b/ui/editor.go
index 444768c..bf21f85 100644
--- a/ui/editor.go
+++ b/ui/editor.go
@@ -56,7 +56,11 @@ func (e *Editor) Resize(width int) {
}

func (e *Editor) IsCommand() bool {
	return len(e.text[e.lineIdx]) != 0 && e.text[e.lineIdx][0] == '/'
	line := e.text[e.lineIdx]

	// Command can't start with two slashes because that's an escape for
	// a literal slash in the message
	return len(line) >= 1 && line[0] == '/' && !(len(line) >= 2 && line[1] == '/')
}

func (e *Editor) TextLen() int {
--
2.31.1
Reply to thread Export thread (mbox)