diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-27 15:49:15 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2025-02-27 15:49:15 +0900 |
| commit | 3ba82b6d87348b119f9a7fd168ad8a597a18b4b2 (patch) | |
| tree | 8c77abbcfbca11d568beaf67f972e246a8e123ba /src/terminal.go | |
| parent | e771c5d057c4a333b2fd37819e5ce6ba719c264c (diff) | |
| download | fzf-3ba82b6d87348b119f9a7fd168ad8a597a18b4b2.tar.gz | |
Make truncateQuery faster
https://github.com/junegunn/fzf/issues/4292#issuecomment-2687051731
Diffstat (limited to 'src/terminal.go')
| -rw-r--r-- | src/terminal.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/terminal.go b/src/terminal.go index 2f00a398..19230a9d 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -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)) } |
