summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Yerin <yyp@disroot.org>2021-06-05 00:09:58 +0300
committerHubert Hirtz <hubert@hirtz.pm>2021-07-08 21:19:16 +0200
commitc4cd304b9aa36ce1332c4a50387b395262534b26 (patch)
treeff04a97410c32ca70bb5eb17d1993d6dc90eb957
parentdoc/senpai.5: mention the issue with \ disappearing (diff)
ui: don't mark // in input as a command
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).
-rw-r--r--ui/editor.go6
1 files changed, 5 insertions, 1 deletions
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 {