Repository: rsteube/carapace (go)

Issue:
xonsh: partially quoted values not completed correctly
Quotes are not removed from prefix if not completely enclosed by the engine and thus included in resulting values.
e.g. multiparts completion when adding a comma to an already quoted prefix:

```sh
carapace-bin/cmd/carapace on  master [$!] via 🐹 v1.17.1
❯ gh issue list --label 'good first issue',<TAB>

# ❯ gh issue list --label r'\'good first issue\',xonsh' 
```

```python
from xonsh.parsers.completion_context import *
CompletionContextParser().parse("gh issue list --label 'good first issue',", 8, None)

#CompletionContext(command=CommandContext(args=(CommandArg(value='gh', opening_quote='', closing_quote=''), CommandArg(value='list', opening_quote='', closing_quote=''), CommandArg(value='--label', opening_quote='', closing_quote=''), CommandArg(value="'good first issue',", opening_quote='', closing_quote='')), arg_index=1, prefix='issue', suffix='', opening_quote='', closing_quote='', is_after_closing_quote=False, subcmd_opening=''), python=PythonContext("gh issue list --label 'good first issue',", 8, is_sub_expression=False))
```


Pull request description:
xonsh: remove quotes from prefix
fix #371

Patch:
diff --git a/README.md b/README.md
index 847f2e6..e0ed65a 100644
--- a/README.md
+++ b/README.md
@@ -78,7 +78,6 @@ set autolist
 eval `example _carapace tcsh`
 
 # xonsh
-$COMPLETION_QUERY_LIMIT = 500 # increase limit
 $PATH.append($(pwd))
 exec($(example _carapace xonsh))
 
diff --git a/internal/xonsh/snippet.go b/internal/xonsh/snippet.go
index ba9c471..8ca4e38 100644
--- a/internal/xonsh/snippet.go
+++ b/internal/xonsh/snippet.go
@@ -20,13 +20,18 @@ def _%v_completer(context):
         from json import loads
         from subprocess import Popen, PIPE
         from xonsh.completers.tools import RichCompletion
-        output, _ = Popen(['%v', '_carapace', 'xonsh', '_', *[a.value for a in context.args], context.prefix], stdout=PIPE, stderr=PIPE).communicate()
+        
+        def fix_prefix(s):
+            """quick fix for partially quoted prefix completion ('prefix',<TAB>)"""
+            return s.translate(str.maketrans('', '', '\'"'))
+
+        output, _ = Popen(['%v', '_carapace', 'xonsh', '_', *[a.value for a in context.args], fix_prefix(context.prefix)], stdout=PIPE, stderr=PIPE).communicate()
         try:
-            result = {RichCompletion(c["Value"], display=c["Display"], description=c["Description"], prefix_len=len(context.raw_prefix)) for c in loads(output)}
+            result = {RichCompletion(c["Value"], display=c["Display"], description=c["Description"], prefix_len=len(context.raw_prefix), append_closing_quote=False) for c in loads(output)}
         except:
             result = {}
         if len(result) == 0:
-            result = {RichCompletion(context.prefix, display=context.prefix, description='', prefix_len=len(context.raw_prefix))}
+            result = {RichCompletion(context.prefix, display=context.prefix, description='', prefix_len=len(context.raw_prefix), append_closing_quote=False)}
         return result
 
 


Test patch:
diff --git a/example/cmd/_test/xonsh.py b/example/cmd/_test/xonsh.py
index c1d4b8a..01d03be 100644
--- a/example/cmd/_test/xonsh.py
+++ b/example/cmd/_test/xonsh.py
@@ -7,13 +7,18 @@ def _example_completer(context):
         from json import loads
         from subprocess import Popen, PIPE
         from xonsh.completers.tools import RichCompletion
-        output, _ = Popen(['example', '_carapace', 'xonsh', '_', *[a.value for a in context.args], context.prefix], stdout=PIPE, stderr=PIPE).communicate()
+        
+        def fix_prefix(s):
+            """quick fix for partially quoted prefix completion ('prefix',<TAB>)"""
+            return s.translate(str.maketrans('', '', '\'"'))
+
+        output, _ = Popen(['example', '_carapace', 'xonsh', '_', *[a.value for a in context.args], fix_prefix(context.prefix)], stdout=PIPE, stderr=PIPE).communicate()
         try:
-            result = {RichCompletion(c["Value"], display=c["Display"], description=c["Description"], prefix_len=len(context.raw_prefix)) for c in loads(output)}
+            result = {RichCompletion(c["Value"], display=c["Display"], description=c["Description"], prefix_len=len(context.raw_prefix), append_closing_quote=False) for c in loads(output)}
         except:
             result = {}
         if len(result) == 0:
-            result = {RichCompletion(context.prefix, display=context.prefix, description='', prefix_len=len(context.raw_prefix))}
+            result = {RichCompletion(context.prefix, display=context.prefix, description='', prefix_len=len(context.raw_prefix), append_closing_quote=False)}
         return result