Repository: rsteube/carapace (go)

Issue:
`()` file completion broken
Files containing `()` are currently truncated: `file()name -> file`

```go
10b4875b54ad7da4f2b6d6e10a7e73a2e219431a is the first bad commit
commit 10b4875b54ad7da4f2b6d6e10a7e73a2e219431a
Author: rsteube <rsteube@users.noreply.github.com>
Date:   Fri May 27 10:23:09 2022 +0200

    ToMultiParts: fix display

 action_test.go        |  1 -
 invokedAction.go      | 50 ++++++++++++++++++++++++++++++++++----------------
 invokedAction_test.go | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 73 insertions(+), 17 deletions(-)
 create mode 100644 invokedAction_test.go
bisect found first bad commit
```

caused-by: #534 

Pull request description:
ToMultiParts: fix bracket completion (incomplete quickfix)
related #554

Patch:
diff --git a/invokedAction.go b/invokedAction.go
index 532533a..2eb45c7 100644
--- a/invokedAction.go
+++ b/invokedAction.go
@@ -105,7 +105,7 @@ func (a InvokedAction) ToMultiPartsA(dividers ...string) Action {
 			for _, d := range dividers {
 				quotedDividiers = append(quotedDividiers, regexp.QuoteMeta(d))
 			}
-			f := fmt.Sprintf("([^(%v)]*(%v)?)", strings.Join(quotedDividiers, "|"), strings.Join(quotedDividiers, "|"))
+			f := fmt.Sprintf("([^%v]*(%v)?)", strings.Join(quotedDividiers, "|"), strings.Join(quotedDividiers, "|")) // TODO quickfix - this is wrong (fails for dividers longer than one character) an might need a reverse lookahead for character sequence
 			r := regexp.MustCompile(f)
 			return func(s string) []string {
 				if matches := r.FindAllString(s, -1); matches != nil {


Test patch:
diff --git a/invokedAction_test.go b/invokedAction_test.go
index 2d13772..d02d288 100644
--- a/invokedAction_test.go
+++ b/invokedAction_test.go
@@ -17,6 +17,7 @@ func TestToMultiParts(t *testing.T) {
 			"B/c:5:1", "fiftyone", style.Black,
 			"B/c:5:2/z", "fiftytwo", style.Yellow,
 			"B/c/", "withsuffix", style.Underlined,
+			"C/d/1()2", "withbrackets", style.Yellow,
 		)
 		a = a.Invoke(Context{}).ToMultiPartsA(delimiter...)
 		if actual := a.Invoke(Context{CallbackValue: cv}).value("export", cv); !strings.Contains(actual, expected) {
@@ -36,4 +37,6 @@ func TestToMultiParts(t *testing.T) {
 	_test("B/c:5", `{"Value":"B/c:5:2/","Display":"c:5:2/","Description":"","Style":""}`, "/")
 	_test("B/c:5", `{"Value":"B/c:5:","Display":"5:","Description":"","Style":""}`, "/", ":")
 	_test("B/c:5", `{"Value":"B/c:5:","Display":"5:","Description":"","Style":""}`, ":", "/")
+
+	_test("C/d/1", `{"Value":"C/d/1()2","Display":"1()2","Description":"withbrackets","Style":"yellow"}`, "/")
 }