Skip to content

Commit ce20936

Browse files
authored
Merge pull request #1104 from carapace-sh/env-unfiltered
env: added `CARAPACE_UNFILTERED`
2 parents 3b08eff + 99d0d50 commit ce20936

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

internal/env/env.go

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
CARAPACE_NOSPACE = "CARAPACE_NOSPACE" // nospace suffixes
2121
CARAPACE_SANDBOX = "CARAPACE_SANDBOX" // mock context for sandbox tests
2222
CARAPACE_TOOLTIP = "CARAPACE_TOOLTIP" // enable tooltip style
23+
CARAPACE_UNFILTERED = "CARAPACE_UNFILTERED" // skip the final filtering step
2324
CARAPACE_ZSH_HASH_DIRS = "CARAPACE_ZSH_HASH_DIRS" // zsh hash directories
2425
CLICOLOR = "CLICOLOR" // disable color
2526
NO_COLOR = "NO_COLOR" // disable color
@@ -81,6 +82,10 @@ func Compline() string {
8182
return os.Getenv(CARAPACE_COMPLINE)
8283
}
8384

85+
func Unfiltered() bool {
86+
return getBool(CARAPACE_UNFILTERED)
87+
}
88+
8489
func getBool(s string) bool {
8590
switch os.Getenv(s) {
8691
case "true", "1":

internal/shell/shell.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,15 @@ func Value(shell string, value string, meta common.Meta, values common.RawValues
7979
style.Carapace.Usage = style.Italic
8080
values = values.Decolor()
8181
}
82-
filtered := values.FilterPrefix(value)
82+
83+
if !env.Unfiltered() {
84+
values = values.FilterPrefix(value)
85+
}
86+
8387
switch shell {
8488
case "elvish", "export", "zsh": // shells with support for showing messages
8589
default:
86-
filtered = meta.Messages.Integrate(filtered, value)
90+
values = meta.Messages.Integrate(values, value)
8791
}
8892

8993
if shell != "export" {
@@ -95,16 +99,16 @@ func Value(shell string, value string, meta common.Meta, values common.RawValues
9599
}
96100
}
97101

98-
sort.Sort(common.ByDisplay(filtered))
102+
sort.Sort(common.ByDisplay(values))
99103
if env.Experimental() {
100104
if _, err := exec.LookPath("tabdance"); err == nil {
101-
return f(value, meta, filtered)
105+
return f(value, meta, values)
102106
}
103107
}
104-
for index := range filtered {
105-
filtered[index].Uid = ""
108+
for index := range values {
109+
values[index].Uid = ""
106110
}
107-
return f(value, meta, filtered)
111+
return f(value, meta, values)
108112
}
109113
return ""
110114
}

0 commit comments

Comments
 (0)