Repository: rsteube/carapace (go)

Issue:
partial completion of optarg arguments broken
```sh
tail --follow=na<TAB>
```

Pull request description:
traverse: fix partial optarg completion
fix #833

Patch:
diff --git a/traverse.go b/traverse.go
index b53145b..970a758 100644
--- a/traverse.go
+++ b/traverse.go
@@ -162,12 +162,11 @@ loop:
 	case !c.DisableFlagParsing && strings.HasPrefix(context.Value, "-") && (fs.IsInterspersed() || len(inPositionals) == 0):
 		if f := fs.LookupArg(context.Value); f != nil && f.IsOptarg() && strings.Contains(context.Value, string(f.OptargDelimiter())) {
 			LOG.Printf("completing optional flag argument for arg %#v\n", context.Value)
-			prefix, optarg := f.Split(context.Value)
-			context.Value = optarg
+			prefix, _ := f.Split(context.Value)
 
 			switch f.Value.Type() {
 			case "bool":
-				return ActionValues("true", "false").StyleF(style.ForKeyword).Prefix(prefix), context
+				return ActionValues("true", "false").StyleF(style.ForKeyword).Usage(f.Usage).Prefix(prefix), context
 			default:
 				return storage.getFlag(c, f.Name).Prefix(prefix), context
 			}


Test patch:
diff --git a/example/cmd/root_test.go b/example/cmd/root_test.go
index 09cfc27..fcd5907 100644
--- a/example/cmd/root_test.go
+++ b/example/cmd/root_test.go
@@ -136,11 +136,38 @@ func TestRoot(t *testing.T) {
 			Expect(carapace.ActionStyledValuesDescribed(
 				"--array", "multiflag", style.Blue,
 			).NoSpace('.').Tag("flags"))
+	})
+}
+
+func TestOptarg(t *testing.T) {
+	sandbox.Package(t, "github.com/rsteube/carapace/example")(func(s *sandbox.Sandbox) {
+		s.Run("--persistentFlag=").
+			Expect(carapace.ActionValues(
+				"p1",
+				"p2",
+				"p3",
+			).Prefix("--persistentFlag=").
+				Usage("Help message for persistentFlag"))
+
+		s.Run("--persistentFlag=p").
+			Expect(carapace.ActionValues(
+				"p1",
+				"p2",
+				"p3",
+			).Prefix("--persistentFlag=").
+				Usage("Help message for persistentFlag"))
 
 		s.Run("--toggle=").
 			Expect(carapace.ActionStyledValues(
+				"true", style.Green,
 				"false", style.Red,
+			).Prefix("--toggle=").
+				Usage("Help message for toggle"))
+
+		s.Run("--toggle=tru").
+			Expect(carapace.ActionStyledValues(
 				"true", style.Green,
-			).Prefix("--toggle="))
+			).Prefix("--toggle=").
+				Usage("Help message for toggle"))
 	})
 }