summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-03-24 17:09:44 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-03-24 17:09:44 +0900
commit200745011afdaf3f2965af021bf52621e4fc54b9 (patch)
tree7597d84b83f6a3327bef032ab10774534044c9fc /src
parent82fd88339b115f1159d66588191990d95fb41e88 (diff)
downloadfzf-200745011afdaf3f2965af021bf52621e4fc54b9.tar.gz
Fix cursor position when prompt is truncated
e.g. fzf --preview 'cat {}' --prompt "$(seq 100 | xargs)" fzf --preview 'cat {}' --prompt "$(seq 100 | xargs)" --input-border
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 81485d6a..1b604828 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1306,8 +1306,11 @@ func (t *Terminal) parsePrompt(prompt string) (func(), int) {
t.wrap = false
t.withWindow(t.inputWindow, func() {
line := t.promptLine()
+ preTask := func(markerClass) int {
+ return 1
+ }
t.printHighlighted(
- Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, nil, nil)
+ Result{item: item}, tui.ColPrompt, tui.ColPrompt, false, false, line, line, true, preTask, nil)
})
t.wrap = wrap
}
@@ -2341,15 +2344,18 @@ func (t *Terminal) placeCursor() {
if t.inputless {
return
}
+ x := t.promptLen + t.queryLen[0]
if t.inputWindow != nil {
y := t.inputWindow.Height() - 1
if t.layout == layoutReverse {
y = 0
}
- t.inputWindow.Move(y, t.promptLen+t.queryLen[0])
+ x = util.Min(x, t.inputWindow.Width()-1)
+ t.inputWindow.Move(y, x)
return
}
- t.move(t.promptLine(), t.promptLen+t.queryLen[0], false)
+ x = util.Min(x, t.window.Width()-1)
+ t.move(t.promptLine(), x, false)
}
func (t *Terminal) printPrompt() {