m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-16 07:13:48 -05:00

Make truncateQuery faster

https://github.com/junegunn/fzf/issues/4292#issuecomment-2687051731
This commit is contained in:
Junegunn Choi
2025-02-27 15:49:15 +09:00
parent e771c5d057
commit 3ba82b6d87

View File

@@ -2286,7 +2286,11 @@ func (t *Terminal) move(y int, x int, clear bool) {
}
func (t *Terminal) truncateQuery() {
t.input, _ = t.trimRight(t.input, maxPatternLength)
// We're limiting the length of the query not to make fzf unresponsive when
// the user accidentally pastes a huge chunk of text. Therefore, we're not
// interested in the exact display width of the query. We just limit the
// number of runes.
t.input = t.input[:util.Min(len(t.input), maxPatternLength)]
t.cx = util.Constrain(t.cx, 0, len(t.input))
}