Always export variables

After some testing, I decided that we should not reset the variables.
Because if we do that, the information becomes unavailable to the
preview process as it runs asynchronously in a different goroutine.

  fzf --header-lines=2 --bind 'click-header:transform-prompt(printf ${FZF_CLICK_HEADER_LINE}x${FZF_CLICK_HEADER_COLUMN})+preview(env | grep FZF)'
pull/3768/head
Junegunn Choi 4 weeks ago
parent b6ead62cd2
commit 354b8b26dc
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

@ -847,10 +847,6 @@ func (t *Terminal) environ() []string {
if t.listenPort != nil { if t.listenPort != nil {
env = append(env, fmt.Sprintf("FZF_PORT=%d", *t.listenPort)) env = append(env, fmt.Sprintf("FZF_PORT=%d", *t.listenPort))
} }
if t.clickHeaderLine > 0 {
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_LINE=%d", t.clickHeaderLine))
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_COLUMN=%d", t.clickHeaderColumn))
}
env = append(env, "FZF_QUERY="+string(t.input)) env = append(env, "FZF_QUERY="+string(t.input))
env = append(env, "FZF_ACTION="+t.lastAction.Name()) env = append(env, "FZF_ACTION="+t.lastAction.Name())
env = append(env, "FZF_KEY="+t.lastKey) env = append(env, "FZF_KEY="+t.lastKey)
@ -863,6 +859,8 @@ func (t *Terminal) environ() []string {
env = append(env, fmt.Sprintf("FZF_LINES=%d", t.areaLines)) env = append(env, fmt.Sprintf("FZF_LINES=%d", t.areaLines))
env = append(env, fmt.Sprintf("FZF_COLUMNS=%d", t.areaColumns)) env = append(env, fmt.Sprintf("FZF_COLUMNS=%d", t.areaColumns))
env = append(env, fmt.Sprintf("FZF_POS=%d", util.Min(t.merger.Length(), t.cy+1))) env = append(env, fmt.Sprintf("FZF_POS=%d", util.Min(t.merger.Length(), t.cy+1)))
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_LINE=%d", t.clickHeaderLine))
env = append(env, fmt.Sprintf("FZF_CLICK_HEADER_COLUMN=%d", t.clickHeaderColumn))
return env return env
} }
@ -4041,11 +4039,7 @@ func (t *Terminal) Loop() {
if my >= 0 && my < numLines && mx >= 0 { if my >= 0 && my < numLines && mx >= 0 {
t.clickHeaderLine = my + 1 t.clickHeaderLine = my + 1
t.clickHeaderColumn = mx + 1 t.clickHeaderColumn = mx + 1
evt := tui.ClickHeader return doActions(actionsFor(tui.ClickHeader))
res := doActions(actionsFor(evt))
t.clickHeaderLine = 0
t.clickHeaderColumn = 0
return res
} }
} }
} }

Loading…
Cancel
Save