nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: rsteube/carapace
Pull request #115 (2020-11-19 23:15:48)

powershell: fix callback placeholder for empty arg


Patch:
diff --git a/powershell/snippet.go b/powershell/snippet.go
index 67ad887..4fea107 100644
--- a/powershell/snippet.go
+++ b/powershell/snippet.go
@@ -50,7 +50,7 @@ $_%v_completer = {
     Function _%v_callback {
       param($uid)
       if (!$wordToComplete) {
-        %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) "''" | Out-String | Invoke-Expression
+        %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '' | Out-String | Invoke-Expression
       } else {
         %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) | Out-String | Invoke-Expression
       }


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index f79f251..ef3d38b 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -566,7 +566,7 @@ $_example_completer = {
     Function _example_callback {
       param($uid)
       if (!$wordToComplete) {
-        example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) "''" | Out-String | Invoke-Expression
+        example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '' | Out-String | Invoke-Expression
       } else {
         example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) | Out-String | Invoke-Expression
       }
Repository: rsteube/carapace
Pull request #119 (2020-11-20 08:52:21)

powershell: fix empty argument passed to command


Patch:
diff --git a/powershell/snippet.go b/powershell/snippet.go
index 4fea107..fe73d04 100644
--- a/powershell/snippet.go
+++ b/powershell/snippet.go
@@ -50,7 +50,7 @@ $_%v_completer = {
     Function _%v_callback {
       param($uid)
       if (!$wordToComplete) {
-        %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '' | Out-String | Invoke-Expression
+        %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '""' | Out-String | Invoke-Expression
       } else {
         %v _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) | Out-String | Invoke-Expression
       }


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index ef3d38b..e2239dd 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -566,7 +566,7 @@ $_example_completer = {
     Function _example_callback {
       param($uid)
       if (!$wordToComplete) {
-        example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '' | Out-String | Invoke-Expression
+        example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) '""' | Out-String | Invoke-Expression
       } else {
         example _carapace powershell "$uid" $($commandElements| Foreach {$_.Extent}) | Out-String | Invoke-Expression
       }
Repository: rsteube/carapace
Pull request #121 (2020-11-21 11:36:20)

elvish: fix eval namespace


Patch:
diff --git a/elvish/snippet.go b/elvish/snippet.go
index c946ad7..9d5ee86 100644
--- a/elvish/snippet.go
+++ b/elvish/snippet.go
@@ -39,7 +39,7 @@ edit:completion:arg-completer[%v] = [@arg]{
     if (eq $arg[-1] "") {
         arg[-1] = "''"
     }
-    eval (echo (str:join ' ' $arg) | xargs %v _carapace elvish $uid | slurp)
+    eval (echo (str:join ' ' $arg) | xargs %v _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
   }
 
   fn subindex [subcommand]{


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index e2239dd..d41a3b2 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -288,7 +288,7 @@ edit:completion:arg-completer[example] = [@arg]{
     if (eq $arg[-1] "") {
         arg[-1] = "''"
     }
-    eval (echo (str:join ' ' $arg) | xargs example _carapace elvish $uid | slurp)
+    eval (echo (str:join ' ' $arg) | xargs example _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
   }
 
   fn subindex [subcommand]{
Repository: rsteube/carapace
Pull request #139 (2020-12-12 00:53:20)

bash: fix multiparts slash
#127 


Patch:
diff --git a/internal/bash/snippet.go b/internal/bash/snippet.go
index 37fdd99..02b1d86 100644
--- a/internal/bash/snippet.go
+++ b/internal/bash/snippet.go
@@ -41,7 +41,7 @@ _%v_completions() {
   local cur prev #words cword split
   _init_completion -n /=:.,
   local curprefix
-  curprefix="$(echo "$cur" | sed -r 's_^(.*[:/=])?.*_\1_')"
+  curprefix="$(echo "$cur" | sed -r 's_^(.*[:=])?.*_\1_')"
   local compline="${COMP_LINE:0:${COMP_POINT}}"
  
   # TODO


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 8aeaa6e..376dc37 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -24,7 +24,7 @@ _example_completions() {
   local cur prev #words cword split
   _init_completion -n /=:.,
   local curprefix
-  curprefix="$(echo "$cur" | sed -r 's_^(.*[:/=])?.*_\1_')"
+  curprefix="$(echo "$cur" | sed -r 's_^(.*[:=])?.*_\1_')"
   local compline="${COMP_LINE:0:${COMP_POINT}}"
  
   # TODO
Repository: rsteube/carapace
Pull request #140 (2020-12-12 14:04:50)

elvish: fix space in values
- changed delimiter for join/xargs

#99 


Patch:
diff --git a/internal/elvish/snippet.go b/internal/elvish/snippet.go
index 162b9f2..22ac334 100644
--- a/internal/elvish/snippet.go
+++ b/internal/elvish/snippet.go
@@ -39,7 +39,7 @@ edit:completion:arg-completer[%v] = [@arg]{
     if (eq $arg[-1] "") {
         arg[-1] = "''"
     }
-    eval (echo (str:join ' ' $arg) | xargs %v _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
+    eval (echo (str:join "\001" $arg) | xargs --delimiter="\001" %v _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
   }
 
   fn subindex [subcommand]{


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 376dc37..9b45504 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -284,7 +284,7 @@ edit:completion:arg-completer[example] = [@arg]{
     if (eq $arg[-1] "") {
         arg[-1] = "''"
     }
-    eval (echo (str:join ' ' $arg) | xargs example _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
+    eval (echo (str:join "\001" $arg) | xargs --delimiter="\001" example _carapace elvish $uid | slurp) &ns=(ns [&arg=$arg])
   }
 
   fn subindex [subcommand]{
Repository: rsteube/carapace
Pull request #171 (2020-12-18 13:49:24)

bash: empty value as dummy works as well
related #164


Patch:
diff --git a/internal/bash/snippet.go b/internal/bash/snippet.go
index c6483f2..94595e6 100644
--- a/internal/bash/snippet.go
+++ b/internal/bash/snippet.go
@@ -67,7 +67,7 @@ _%v_completions() {
     value="${entry%%	*}"
     display="${entry#*	}"
     if [[ "${value::1}" != "${display::1}"  ]]; then # inserted value differs from display value
-       [[ "$(printf  "%%c\n" "${COMPREPLY[@]#*	}" | uniq | wc -l)" -eq 1 ]] && COMPREPLY=("${COMPREPLY[@]}" "_ (ignore me)") # prevent insertion if all have same first character (workaround for #164)
+       [[ "$(printf  "%%c\n" "${COMPREPLY[@]#*	}" | uniq | wc -l)" -eq 1 ]] && COMPREPLY=("${COMPREPLY[@]}" "") # prevent insertion if all have same first character (workaround for #164)
       break
     fi
   done


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 2e06247..93bad6e 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -271,7 +271,7 @@ _example_completions() {
     value="${entry%	*}"
     display="${entry#*	}"
     if [[ "${value::1}" != "${display::1}"  ]]; then # inserted value differs from display value
-       [[ "$(printf  "%c\n" "${COMPREPLY[@]#*	}" | uniq | wc -l)" -eq 1 ]] && COMPREPLY=("${COMPREPLY[@]}" "_ (ignore me)") # prevent insertion if all have same first character (workaround for #164)
+       [[ "$(printf  "%c\n" "${COMPREPLY[@]#*	}" | uniq | wc -l)" -eq 1 ]] && COMPREPLY=("${COMPREPLY[@]}" "") # prevent insertion if all have same first character (workaround for #164)
       break
     fi
   done
Repository: rsteube/carapace
Pull request #224 (2021-01-13 15:28:07)

fish: remove eval
related #3
related #192
related #194
related #215


Patch:
diff --git a/internal/fish/action.go b/internal/fish/action.go
index 32baab3..fbdf83f 100644
--- a/internal/fish/action.go
+++ b/internal/fish/action.go
@@ -1,10 +1,8 @@
 package fish
 
 import (
-	"fmt"
-	"strings"
-
 	"github.com/rsteube/carapace/internal/common"
+	"strings"
 )
 
 var sanitizer = strings.NewReplacer(
@@ -29,9 +27,7 @@ func Sanitize(values ...string) []string {
 func ActionRawValues(callbackValues string, values ...common.RawValue) string {
 	vals := make([]string, len(values))
 	for index, val := range values {
-		// TODO sanitize
-		//vals[index] = strings.Replace(val, " ", `\ `, -1)
 		vals[index] = sanitizer.Replace(val.Value) + "\t" + sanitizer.Replace(val.Description)
 	}
-	return fmt.Sprintf(`echo -e "%v"`, strings.Join(vals, `\n`))
+	return strings.Join(vals, "\n")
 }
diff --git a/internal/fish/snippet.go b/internal/fish/snippet.go
index bb93b3f..32033a2 100644
--- a/internal/fish/snippet.go
+++ b/internal/fish/snippet.go
@@ -31,8 +31,7 @@ func Snippet(cmd *cobra.Command, actions map[string]string) string {
 end
 
 function _%v_callback
-  set -lx CALLBACK (commandline -cp | sed "s/\$/"(_%v_quote_suffix)"/" | sed "s/ \$/ ''/" | xargs %v _carapace fish _ )
-  eval "$CALLBACK"
+  commandline -cp | sed "s/\$/"(_%v_quote_suffix)"/" | sed "s/ \$/ ''/" | xargs %v _carapace fish _
 end
 
 complete -c %v -f


Test patch:
diff --git a/example/cmd/_test/fish.fish b/example/cmd/_test/fish.fish
index 5128f9c..33ab6fd 100644
--- a/example/cmd/_test/fish.fish
+++ b/example/cmd/_test/fish.fish
@@ -11,8 +11,7 @@ function _example_quote_suffix
 end
 
 function _example_callback
-  set -lx CALLBACK (commandline -cp | sed "s/\$/"(_example_quote_suffix)"/" | sed "s/ \$/ ''/" | xargs example _carapace fish _ )
-  eval "$CALLBACK"
+  commandline -cp | sed "s/\$/"(_example_quote_suffix)"/" | sed "s/ \$/ ''/" | xargs example _carapace fish _
 end
 
 complete -c example -f
Repository: rsteube/carapace
Pull request #225 (2021-01-14 00:03:01)

zsh: removed eval
related #3
related #192
related #194
related #215


Patch:
diff --git a/internal/zsh/action.go b/internal/zsh/action.go
index f2c1e40..a1d4723 100644
--- a/internal/zsh/action.go
+++ b/internal/zsh/action.go
@@ -49,14 +49,12 @@ func ActionRawValues(callbackValue string, values ...common.RawValue) string {
 	}
 
 	vals := make([]string, len(filtered))
-	displays := make([]string, len(filtered))
 	for index, val := range filtered {
-		vals[index] = fmt.Sprintf("'%v'", EscapeSpace(sanitizer.Replace(val.Value)))
 		if strings.TrimSpace(val.Description) == "" {
-			displays[index] = fmt.Sprintf("'%v'", sanitizer.Replace(val.Display))
+			vals[index] = fmt.Sprintf("%v\t%v", EscapeSpace(sanitizer.Replace(val.Value)), sanitizer.Replace(val.Display))
 		} else {
-			displays[index] = fmt.Sprintf("'%v (%v)'", sanitizer.Replace(val.Display), sanitizer.Replace(val.Description))
+			vals[index] = fmt.Sprintf("%v\t%v (%v)", EscapeSpace(sanitizer.Replace(val.Value)), sanitizer.Replace(val.Display), sanitizer.Replace(val.Description))
 		}
 	}
-	return fmt.Sprintf("{local _comp_desc=(%v);compadd -Q -S '' -d _comp_desc -- %v}", strings.Join(displays, " "), strings.Join(vals, " "))
+	return strings.Join(vals, "\n")
 }
diff --git a/internal/zsh/snippet.go b/internal/zsh/snippet.go
index d6fd71e..3885d9a 100644
--- a/internal/zsh/snippet.go
+++ b/internal/zsh/snippet.go
@@ -20,9 +20,14 @@ var replacer = strings.NewReplacer(
 func Snippet(cmd *cobra.Command, actions map[string]string) string {
 	return fmt.Sprintf(`#compdef %v
 function _%v_completion {
-  # shellcheck disable=SC2086
-  eval "$(%v _carapace zsh _ ${^words//\\ / }'')"
-
+  local IFS=$'\n'
+  # shellcheck disable=SC2207,SC2086
+  local c=($(%v _carapace zsh _ ${^words//\\ / }''))
+  # shellcheck disable=SC2034,2206
+  local vals=(${c%%%%$'\t'*})
+  # shellcheck disable=SC2034,2206
+  local descriptions=(${c##*$'\t'})
+  compadd -Q -S '' -d descriptions -a -- vals
 }
 compquote '' 2>/dev/null && _%v_completion
 compdef _%v_completion %v


Test patch:
diff --git a/example/cmd/_test/zsh.sh b/example/cmd/_test/zsh.sh
index 1e12b21..7bedd0d 100644
--- a/example/cmd/_test/zsh.sh
+++ b/example/cmd/_test/zsh.sh
@@ -1,8 +1,13 @@
 #compdef example
 function _example_completion {
-  # shellcheck disable=SC2086
-  eval "$(example _carapace zsh _ ${^words//\\ / }'')"
-
+  local IFS=$'\n'
+  # shellcheck disable=SC2207,SC2086
+  local c=($(example _carapace zsh _ ${^words//\\ / }''))
+  # shellcheck disable=SC2034,2206
+  local vals=(${c%%$'\t'*})
+  # shellcheck disable=SC2034,2206
+  local descriptions=(${c##*$'\t'})
+  compadd -Q -S '' -d descriptions -a -- vals
 }
 compquote '' 2>/dev/null && _example_completion
 compdef _example_completion example
Repository: rsteube/carapace
Pull request #263 (2021-03-22 20:26:51)

xonsh: use raw strings
related #215 


Patch:
diff --git a/example/cmd/_test_files/space .txt b/example/cmd/_test_files/space_ .txt
similarity index 100%
rename from example/cmd/_test_files/space .txt
rename to example/cmd/_test_files/space_ .txt
diff --git a/internal/xonsh/action.go b/internal/xonsh/action.go
index 61ee8e7..08bda51 100644
--- a/internal/xonsh/action.go
+++ b/internal/xonsh/action.go
@@ -11,7 +11,7 @@ import (
 var sanitizer = strings.NewReplacer( // TODO
 	"\n", ``,
 	"\t", ``,
-	`'`, ``, // `\'` seems to work but beware of `\\'`
+	`'`, `\'`,
 )
 
 func Sanitize(values ...string) []string {
@@ -41,8 +41,12 @@ func ActionRawValues(callbackValue string, values ...common.RawValue) string {
 	for index, val := range filtered {
 		val.Value = sanitizer.Replace(val.Value)
 
-		if strings.ContainsAny(val.Value, ` ()[]*$?\"|<>&();#`+"`") {
-			val.Value = fmt.Sprintf("'%v'", val.Value)
+		if strings.ContainsAny(val.Value, ` ()[]{}*$?\"|<>&;#`+"`") {
+			if strings.Contains(val.Value, `\`) {
+				val.Value = fmt.Sprintf("r'%v'", val.Value) // backslash needs raw string
+			} else {
+				val.Value = fmt.Sprintf("'%v'", val.Value)
+			}
 		}
 		vals[index] = richCompletion{Value: val.Value, Display: val.Display, Description: val.Description}
 	}
diff --git a/internal/xonsh/snippet.go b/internal/xonsh/snippet.go
index ff2f7c4..69afbc2 100644
--- a/internal/xonsh/snippet.go
+++ b/internal/xonsh/snippet.go
@@ -40,6 +40,10 @@ func Snippet(cmd *cobra.Command) string {
             begidx = begidx - len(word)
             if line[begidx-1] == " ":
                 break
+    
+    for index, item in enumerate(wordsNonPosix):
+        if item.startswith("r'"):
+            words[index] = words[index][1:] # fix rawstring not handled by shlex
 
     current=words[-1]
     previous=words[-2]


Test patch:
diff --git a/example/cmd/_test/xonsh.py b/example/cmd/_test/xonsh.py
index 3df6ca5..fc99a1f 100644
--- a/example/cmd/_test/xonsh.py
+++ b/example/cmd/_test/xonsh.py
@@ -28,6 +28,10 @@ def _example_completer(prefix, line, begidx, endidx, ctx):
             begidx = begidx - len(word)
             if line[begidx-1] == " ":
                 break
+    
+    for index, item in enumerate(wordsNonPosix):
+        if item.startswith("r'"):
+            words[index] = words[index][1:] # fix rawstring not handled by shlex
 
     current=words[-1]
     previous=words[-2]
Repository: rsteube/carapace
Pull request #274 (2021-04-07 12:37:39)

oil: implicit nospace


Patch:
diff --git a/internal/oil/action.go b/internal/oil/action.go
index 84a9998..1fc75b2 100644
--- a/internal/oil/action.go
+++ b/internal/oil/action.go
@@ -20,6 +20,8 @@ func Sanitize(values ...string) []string {
 	return sanitized
 }
 
+const nospaceIndicator = "\001"
+
 func ActionRawValues(callbackValue string, nospace bool, values ...common.RawValue) string {
 	filtered := make([]common.RawValue, 0)
 
@@ -32,6 +34,10 @@ func ActionRawValues(callbackValue string, nospace bool, values ...common.RawVal
 
 	vals := make([]string, len(filtered))
 	for index, val := range filtered {
+		if nospace && !strings.HasSuffix(val.Value, nospaceIndicator) {
+			val.Value = val.Value + nospaceIndicator
+		}
+
 		if len(filtered) == 1 {
 			formattedVal := sanitizer.Replace(val.Value)
 			vals[index] = formattedVal
diff --git a/internal/oil/snippet.go b/internal/oil/snippet.go
index d4e6aae..e7569db 100644
--- a/internal/oil/snippet.go
+++ b/internal/oil/snippet.go
@@ -14,7 +14,10 @@ _%v_completion() {
   local IFS=$'\n'
   mapfile -t COMPREPLY < <(echo "$compline" | sed -e "s/ \$/ ''/" -e 's/"/\"/g' | xargs %v _carapace oil "_")
   [[ "${COMPREPLY[@]}" == "" ]] && COMPREPLY=() # fix for mapfile creating a non-empty array from empty command output
-  [[ ${COMPREPLY[0]} == *[/=@:.,] ]] && compopt -o nospace
+  [[ ${COMPREPLY[0]} == *[/=@:.,$'\001'] ]] && compopt -o nospace
+  # TODO use mapfile
+  # shellcheck disable=SC2206
+  [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=(${COMPREPLY[@]%%$'\001'})
 }
 
 complete -F _%v_completion %v


Test patch:
diff --git a/example/cmd/_test/oil.sh b/example/cmd/_test/oil.sh
new file mode 100644
index 0000000..978acaa
--- /dev/null
+++ b/example/cmd/_test/oil.sh
@@ -0,0 +1,14 @@
+#!/bin/osh
+_example_completion() {
+  local compline="${COMP_LINE:0:${COMP_POINT}}"
+  local IFS=$'\n'
+  mapfile -t COMPREPLY < <(echo "$compline" | sed -e "s/ \$/ ''/" -e 's/"/\"/g' | xargs example _carapace oil "_")
+  [[ "${COMPREPLY[@]}" == "" ]] && COMPREPLY=() # fix for mapfile creating a non-empty array from empty command output
+  [[ ${COMPREPLY[0]} == *[/=@:.,$'\001'] ]] && compopt -o nospace
+  # TODO use mapfile
+  # shellcheck disable=SC2206
+  [[ ${#COMPREPLY[@]} -eq 1 ]] && COMPREPLY=(${COMPREPLY[@]%$'\001'})
+}
+
+complete -F _example_completion example
+
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 42b3143..18cccce 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -30,6 +30,10 @@ func TestFish(t *testing.T) {
 	testScript(t, "fish", "./_test/fish.fish")
 }
 
+func TestOil(t *testing.T) {
+	testScript(t, "oil", "./_test/oil.sh")
+}
+
 func TestPowershell(t *testing.T) {
 	testScript(t, "powershell", "./_test/powershell.ps1")
 }
Repository: rsteube/carapace
Pull request #301 (2021-05-12 09:15:34)

ignore invalid argument for flag currently completed


Patch:
diff --git a/internal/common/traverse.go b/internal/common/traverse.go
index f4f7547..2947581 100644
--- a/internal/common/traverse.go
+++ b/internal/common/traverse.go
@@ -2,6 +2,7 @@ package common
 
 import (
 	"fmt"
+	"regexp"
 	"strings"
 
 	"github.com/spf13/cobra"
@@ -69,6 +70,11 @@ func filterError(args []string, err error) error {
 			// ignore shorthand flag argument currently being completed
 			return nil
 		}
+
+		if re := regexp.MustCompile(`invalid argument ".*" for "(?P<flag>.*)" flag:.*`); re.MatchString(msg) && previous == re.FindStringSubmatch(msg)[1] {
+			// ignore invalid argument for flag currently being completed (e.g. empty IntSlice)
+			return nil
+		}
 	}
 	return err
 }


Test patch:
diff --git a/internal/common/traverse_test.go b/internal/common/traverse_test.go
index b39ac29..73de9f3 100644
--- a/internal/common/traverse_test.go
+++ b/internal/common/traverse_test.go
@@ -18,6 +18,7 @@ func init() {
 	testCmd.Flags().StringP("optarg", "o", "", "optarg flag")
 	testCmd.Flags().StringP("string", "s", "", "string flag")
 	testCmd.Flags().BoolP("bool", "b", false, "bool flag")
+	testCmd.Flags().IntSlice("intslice", []int{}, "intlice flag")
 
 	testSubCmd.Flags().StringP("suboptarg", "o", "", "optarg flag")
 	testSubCmd.Flags().StringP("substring", "s", "", "string flag")
@@ -66,3 +67,11 @@ func TestShortFlagChainNoArg(t *testing.T) {
 func TestShortFlagChainEmptyArg(t *testing.T) {
 	testTraverseLenient(t, "test", "-bs", "")
 }
+
+func TestIntSliceEmptyArg(t *testing.T) {
+	testTraverseLenient(t, "test", "--intslice", "")
+}
+
+func TestIntSliceIncompleteArg(t *testing.T) {
+	testTraverseLenient(t, "test", "--intslice", "1,")
+}
Repository: rsteube/carapace
Pull request #302 (2021-05-18 19:51:34)

ignore int flag parse error during completion


Patch:
diff --git a/README.md b/README.md
index 098852e..369ac15 100644
--- a/README.md
+++ b/README.md
@@ -93,9 +93,8 @@ example <TAB>
 
 - [carapace-bin](https://github.com/rsteube/carapace-bin) multi-shell multi-command argument completer
 - [gh](https://github.com/rsteube/gh) github cli with added completions (fork)
-- [glab](https://github.com/rsteube/glab) cli client for GitLab (fork)
-- [go-jira-cli](https://github.com/rsteube/go-jira-cli) simple jira command line client
 - [lab](https://github.com/zaquestion/lab) cli client for GitLab
+- [glab](https://github.com/rsteube/glab) cli client for GitLab (fork)
 - [pulumi](https://github.com/rsteube/pulumi) pulumi cli with added completions (fork)
 
 [cobra]:https://github.com/spf13/cobra
diff --git a/internal/common/traverse.go b/internal/common/traverse.go
index 2947581..325db98 100644
--- a/internal/common/traverse.go
+++ b/internal/common/traverse.go
@@ -71,7 +71,7 @@ func filterError(args []string, err error) error {
 			return nil
 		}
 
-		if re := regexp.MustCompile(`invalid argument ".*" for "(?P<flag>.*)" flag:.*`); re.MatchString(msg) && previous == re.FindStringSubmatch(msg)[1] {
+		if re := regexp.MustCompile(`invalid argument ".*" for "(?P<shorthand>-., )?(?P<flag>.*)" flag:.*`); re.MatchString(msg) && previous == re.FindStringSubmatch(msg)[2] {
 			// ignore invalid argument for flag currently being completed (e.g. empty IntSlice)
 			return nil
 		}


Test patch:
diff --git a/internal/common/traverse_test.go b/internal/common/traverse_test.go
index 73de9f3..5524704 100644
--- a/internal/common/traverse_test.go
+++ b/internal/common/traverse_test.go
@@ -14,10 +14,14 @@ var testSubCmd = &cobra.Command{
 	Use: "sub",
 }
 
+var intVar int
+
 func init() {
 	testCmd.Flags().StringP("optarg", "o", "", "optarg flag")
 	testCmd.Flags().StringP("string", "s", "", "string flag")
 	testCmd.Flags().BoolP("bool", "b", false, "bool flag")
+	testCmd.Flags().IntP("int", "i", 0, "int flag")
+	testCmd.Flags().IntVar(&intVar, "intvar", 0, "int flag")
 	testCmd.Flags().IntSlice("intslice", []int{}, "intlice flag")
 
 	testSubCmd.Flags().StringP("suboptarg", "o", "", "optarg flag")
@@ -68,6 +72,14 @@ func TestShortFlagChainEmptyArg(t *testing.T) {
 	testTraverseLenient(t, "test", "-bs", "")
 }
 
+func TestIntEmptyArg(t *testing.T) {
+	testTraverseLenient(t, "test", "--int", "")
+}
+
+func TestIntVarEmptyArg(t *testing.T) {
+	testTraverseLenient(t, "test", "--intvar", "")
+}
+
 func TestIntSliceEmptyArg(t *testing.T) {
 	testTraverseLenient(t, "test", "--intslice", "")
 }