summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-08 10:00:57 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-08 10:00:57 +0900
commit6783417504a2e2a378b8a55a5dd111c18a051425 (patch)
treebdc79dcb2e85339d0b59a45b9adcea718cb5e00b /src
parentfa3f706e71496af5e2c8bfc6bbf6c70de9414827 (diff)
downloadfzf-6783417504a2e2a378b8a55a5dd111c18a051425.tar.gz
Do not export $LINES and $COLUMNS for non-preview processes
Fix #4164
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/terminal.go b/src/terminal.go
index cb560b90..2723d9d7 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1012,6 +1012,14 @@ func (t *Terminal) deferActivation() bool {
}
func (t *Terminal) environ() []string {
+ return t.environImpl(false)
+}
+
+func (t *Terminal) environForPreview() []string {
+ return t.environImpl(true)
+}
+
+func (t *Terminal) environImpl(forPreview bool) []string {
env := os.Environ()
if t.listenPort != nil {
env = append(env, fmt.Sprintf("FZF_PORT=%d", *t.listenPort))
@@ -1037,9 +1045,11 @@ func (t *Terminal) environ() []string {
if pwindowSize.Lines > 0 {
lines := fmt.Sprintf("LINES=%d", pwindowSize.Lines)
columns := fmt.Sprintf("COLUMNS=%d", pwindowSize.Columns)
- env = append(env, lines)
+ if forPreview {
+ env = append(env, lines)
+ env = append(env, columns)
+ }
env = append(env, "FZF_PREVIEW_"+lines)
- env = append(env, columns)
env = append(env, "FZF_PREVIEW_"+columns)
env = append(env, fmt.Sprintf("FZF_PREVIEW_TOP=%d", t.tui.Top()+t.pwindow.Top()))
env = append(env, fmt.Sprintf("FZF_PREVIEW_LEFT=%d", t.pwindow.Left()))
@@ -4132,7 +4142,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.environ()})
+ t.previewBox.Set(reqPreviewEnqueue, previewRequest{command, t.evaluateScrollOffset(), list, t.environForPreview()})
}
}
@@ -4524,7 +4534,7 @@ func (t *Terminal) Loop() error {
if valid {
t.cancelPreview()
t.previewBox.Set(reqPreviewEnqueue,
- previewRequest{t.previewOpts.command, t.evaluateScrollOffset(), list, t.environ()})
+ previewRequest{t.previewOpts.command, t.evaluateScrollOffset(), list, t.environForPreview()})
}
} else {
// Discard the preview content so that it won't accidentally appear