Skip to content

Commit

Permalink
env: added CARAPACE_UNFILTERED
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jan 22, 2025
1 parent 3b08eff commit 99d0d50
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const (
CARAPACE_NOSPACE = "CARAPACE_NOSPACE" // nospace suffixes
CARAPACE_SANDBOX = "CARAPACE_SANDBOX" // mock context for sandbox tests
CARAPACE_TOOLTIP = "CARAPACE_TOOLTIP" // enable tooltip style
CARAPACE_UNFILTERED = "CARAPACE_UNFILTERED" // skip the final filtering step
CARAPACE_ZSH_HASH_DIRS = "CARAPACE_ZSH_HASH_DIRS" // zsh hash directories
CLICOLOR = "CLICOLOR" // disable color
NO_COLOR = "NO_COLOR" // disable color
Expand Down Expand Up @@ -81,6 +82,10 @@ func Compline() string {
return os.Getenv(CARAPACE_COMPLINE)
}

func Unfiltered() bool {
return getBool(CARAPACE_UNFILTERED)
}

func getBool(s string) bool {
switch os.Getenv(s) {
case "true", "1":
Expand Down
18 changes: 11 additions & 7 deletions internal/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,15 @@ func Value(shell string, value string, meta common.Meta, values common.RawValues
style.Carapace.Usage = style.Italic
values = values.Decolor()
}
filtered := values.FilterPrefix(value)

if !env.Unfiltered() {
values = values.FilterPrefix(value)
}

switch shell {
case "elvish", "export", "zsh": // shells with support for showing messages
default:
filtered = meta.Messages.Integrate(filtered, value)
values = meta.Messages.Integrate(values, value)
}

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

sort.Sort(common.ByDisplay(filtered))
sort.Sort(common.ByDisplay(values))
if env.Experimental() {
if _, err := exec.LookPath("tabdance"); err == nil {
return f(value, meta, filtered)
return f(value, meta, values)
}
}
for index := range filtered {
filtered[index].Uid = ""
for index := range values {
values[index].Uid = ""
}
return f(value, meta, filtered)
return f(value, meta, values)
}
return ""
}

0 comments on commit 99d0d50

Please sign in to comment.