Skip to content

Commit

Permalink
Make truncateQuery faster
Browse files Browse the repository at this point in the history
  • Loading branch information
junegunn committed Feb 27, 2025
1 parent e771c5d commit 3ba82b6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down

0 comments on commit 3ba82b6

Please sign in to comment.