commit c4cd304
Alexey Yerin
·
2021-06-04 21:09:58 +0000 UTC
parent 6be7183
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).
1 files changed,
+5,
-1
+5,
-1
1@@ -56,7 +56,11 @@ func (e *Editor) Resize(width int) {
2 }
3
4 func (e *Editor) IsCommand() bool {
5- return len(e.text[e.lineIdx]) != 0 && e.text[e.lineIdx][0] == '/'
6+ line := e.text[e.lineIdx]
7+
8+ // Command can't start with two slashes because that's an escape for
9+ // a literal slash in the message
10+ return len(line) >= 1 && line[0] == '/' && !(len(line) >= 2 && line[1] == '/')
11 }
12
13 func (e *Editor) TextLen() int {