Repository: rsteube/carapace (go)

Issue:
flag completion for embedded dash command broken
```sh
example action -- --<TAB> # no results
example action -- -<TAB> # completes longhand flags
```

Pull request:
traverse: fix dash flag completion
fix #710

Patch:
diff --git a/traverse.go b/traverse.go
index a2ae58e..b18d8e1 100644
--- a/traverse.go
+++ b/traverse.go
@@ -137,7 +137,7 @@ loop:
 	// dash argument
 	case common.IsDash(c):
 		logger.Printf("completing dash for arg %#v\n", context.CallbackValue)
-		context.Args = c.Flags().Args()[c.ArgsLenAtDash():]
+		context.Args = c.Flags().Args()[c.ArgsLenAtDash()+1:]
 		return storage.getPositional(c, len(context.Args)), context
 
 	// flag argument


Test patch:
diff --git a/example/cmd/action_test.go b/example/cmd/action_test.go
index b118434..c7a213c 100644
--- a/example/cmd/action_test.go
+++ b/example/cmd/action_test.go
@@ -164,6 +164,28 @@ func TestAction(t *testing.T) {
 	})
 }
 
+func TestDash(t *testing.T) {
+	sandbox.Package(t, "github.com/rsteube/carapace/example")(func(s *sandbox.Sandbox) {
+		s.Run("action", "--", "").
+			Expect(carapace.ActionValues("embeddedP1", "embeddedPositional1").
+				Usage("action [pos1] [pos2] [--] [dashAny]..."))
+
+		s.Run("action", "--", "-").
+			Expect(carapace.ActionValuesDescribed(
+				"--embedded-flag", "embedded flag").
+				NoSpace('.').
+				Usage("action [pos1] [pos2] [--] [dashAny]...").
+				Tag("flags"))
+
+		s.Run("action", "--", "--").
+			Expect(carapace.ActionValuesDescribed(
+				"--embedded-flag", "embedded flag").
+				NoSpace('.').
+				Usage("action [pos1] [pos2] [--] [dashAny]...").
+				Tag("flags"))
+	})
+}
+
 func TestUnknownFlag(t *testing.T) {
 	sandbox.Package(t, "github.com/rsteube/carapace/example")(func(s *sandbox.Sandbox) {
 		s.Run("action", "--unknown", "").