mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-13 22:03:47 -05:00
Fix {q} in preview window affected by 'search' action
This commit is contained in:
@@ -638,6 +638,7 @@ type previewRequest struct {
|
||||
scrollOffset int
|
||||
list []*Item
|
||||
env []string
|
||||
query string
|
||||
}
|
||||
|
||||
type previewResult struct {
|
||||
@@ -4385,6 +4386,7 @@ func (t *Terminal) Loop() error {
|
||||
var items []*Item
|
||||
var commandTemplate string
|
||||
var env []string
|
||||
var query string
|
||||
initialOffset := 0
|
||||
t.previewBox.Wait(func(events *util.Events) {
|
||||
for req, value := range *events {
|
||||
@@ -4398,6 +4400,7 @@ func (t *Terminal) Loop() error {
|
||||
initialOffset = request.scrollOffset
|
||||
items = request.list
|
||||
env = request.env
|
||||
query = request.query
|
||||
}
|
||||
}
|
||||
events.Clear()
|
||||
@@ -4411,8 +4414,7 @@ func (t *Terminal) Loop() error {
|
||||
version++
|
||||
// We don't display preview window if no match
|
||||
if items[0] != nil {
|
||||
_, query := t.Input()
|
||||
command, tempFiles := t.replacePlaceholder(commandTemplate, false, string(query), items)
|
||||
command, tempFiles := t.replacePlaceholder(commandTemplate, false, query, items)
|
||||
cmd := t.executor.ExecCommand(command, true)
|
||||
cmd.Env = env
|
||||
|
||||
@@ -4540,7 +4542,7 @@ func (t *Terminal) Loop() error {
|
||||
if len(command) > 0 && t.canPreview() {
|
||||
_, list := t.buildPlusList(command, false)
|
||||
t.cancelPreview()
|
||||
t.previewBox.Set(reqPreviewEnqueue, previewRequest{command, t.evaluateScrollOffset(), list, t.environForPreview()})
|
||||
t.previewBox.Set(reqPreviewEnqueue, previewRequest{command, t.evaluateScrollOffset(), list, t.environForPreview(), string(t.input)})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4972,7 +4974,7 @@ func (t *Terminal) Loop() error {
|
||||
if valid {
|
||||
t.cancelPreview()
|
||||
t.previewBox.Set(reqPreviewEnqueue,
|
||||
previewRequest{t.previewOpts.command, t.evaluateScrollOffset(), list, t.environForPreview()})
|
||||
previewRequest{t.previewOpts.command, t.evaluateScrollOffset(), list, t.environForPreview(), string(t.input)})
|
||||
}
|
||||
} else {
|
||||
// Discard the preview content so that it won't accidentally appear
|
||||
|
||||
Reference in New Issue
Block a user