Truncate the query string if it's too long

Use hard-coded limit to keep it simple. An alternative is to dynamically
calculate the width of the visible area and use it as the limit, but it
can cause unwanted truncation of the query on screen resize/split.
This commit is contained in:
Junegunn Choi 2016-09-18 04:20:29 +09:00
parent 2fc7c18747
commit 1854922f0c
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 9 additions and 3 deletions

View File

@ -22,6 +22,7 @@ const (
initialDelay = 20 * time.Millisecond
initialDelayTac = 100 * time.Millisecond
spinnerDuration = 200 * time.Millisecond
maxPatternLength = 100
// Matcher
numPartitionsMultiplier = 8

View File

@ -1337,6 +1337,11 @@ func (t *Terminal) Loop() {
if !doAction(action, mapkey) {
continue
}
// Truncate the query if it's too long
if len(t.input) > maxPatternLength {
t.input = t.input[:maxPatternLength]
t.cx = util.Constrain(t.cx, 0, maxPatternLength)
}
changed = string(previousInput) != string(t.input)
} else {
if mapkey == C.Rune {