Skip to content

Commit 33b1fc3

Browse files
committed
fix(complete): Fix env leakage in elvish dynamic completion
1 parent e5f1f48 commit 33b1fc3

File tree

2 files changed

+2
-10
lines changed
  • clap_complete
    • src/env
    • tests/snapshots/home/dynamic-env/exhaustive/elvish/elvish

2 files changed

+2
-10
lines changed

clap_complete/src/env/shells.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,10 @@ impl EnvCompleter for Elvish {
157157

158158
let script = r#"
159159
set edit:completion:arg-completer[BIN] = { |@words|
160-
set E:_CLAP_IFS = "\n"
161-
162160
var index = (count $words)
163161
set index = (- $index 1)
164-
set E:_CLAP_COMPLETE_INDEX = (to-string $index)
165-
set E:VAR = "elvish"
166162
167-
put (COMPLETER -- $@words) | to-lines
163+
put (env _CLAP_IFS="\n" _CLAP_COMPLETE_INDEX=(to-string $index) VAR="elvish" COMPLETER -- $@words) | to-lines
168164
}
169165
"#
170166
.replace("COMPLETER", &completer)

clap_complete/tests/snapshots/home/dynamic-env/exhaustive/elvish/elvish/rc.elv

+1-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ set edit:rprompt = (constantly "")
22
set edit:prompt = (constantly "% ")
33

44
set edit:completion:arg-completer[exhaustive] = { |@words|
5-
set E:_CLAP_IFS = "\n"
6-
75
var index = (count $words)
86
set index = (- $index 1)
9-
set E:_CLAP_COMPLETE_INDEX = (to-string $index)
10-
set E:COMPLETE = "elvish"
117

12-
put (exhaustive -- $@words) | to-lines
8+
put (env _CLAP_IFS="\n" _CLAP_COMPLETE_INDEX=(to-string $index) COMPLETE="elvish" exhaustive -- $@words) | to-lines
139
}
1410

1511

0 commit comments

Comments
 (0)