Repository: xonsh/xonsh

Issue:
Hints for the `dd` command do not work properly.
When I use a prompt, I expect the path to be completed, but instead the entire path is appended to the end of what I have already written. I have not noticed this with other commands. So I think this is only a problem with the `dd` command.
## For community
⬇️  **Please click the 👍 reaction instead of leaving a `+1` or 👍  comment**



Discussion:
Thanks for reporting @WojAbuk -- I think this has been fixed on `main` -- can you try out installing from `main` and see if that fixes your issue?

We're overdue for a release, too -- I'll leave this open until we confirm whether or not it's fixed.
I installed xonsh-git for AUR (previously I had the binary from the arch repository installed). The same error occurs on both versions. I do not know if this is the main version and I do not know how to install a newer version than in AUR, if there is one.
Hi @gforsyth I just checked, and this is still an issue on `main`.

Resolving patch:
diff --git a/xonsh/completers/bash_completion.py b/xonsh/completers/bash_completion.py
--- a/xonsh/completers/bash_completion.py
+++ b/xonsh/completers/bash_completion.py
@@ -427,6 +427,12 @@ def bash_completions(
     if "-o nospace" in complete_stmt:
         out = {x.rstrip() for x in out}
 
+    # For arguments like 'status=progress', the completion script only returns
+    # the part after '=' in the completion results. This causes the strip_len
+    # to be incorrectly calculated, so it needs to be fixed here
+    if "=" in prefix and "=" not in commprefix:
+        strip_len = prefix.index("=") + 1
+
     return out, max(len(prefix) - strip_len, 0)
 
 


Test patch:
diff --git a/tests/completers/test_bash_completer.py b/tests/completers/test_bash_completer.py
--- a/tests/completers/test_bash_completer.py
+++ b/tests/completers/test_bash_completer.py
@@ -184,28 +184,51 @@ def test_bash_completer_empty_prefix():
 @skip_if_on_darwin
 @skip_if_on_windows
 @pytest.mark.parametrize(
-    "command_context, completions, lprefix",
+    "command_context, completions, lprefix, exp_append_space",
     (
         # dd sta  ->  dd status=
         (
             CommandContext(args=(CommandArg("dd"),), arg_index=1, prefix="sta"),
             {"status="},
             3,
+            False,
         ),
         # date --da  ->  date --date=
         (
             CommandContext(args=(CommandArg("date"),), arg_index=1, prefix="--da"),
             {"--date="},
             4,
+            False,
+        ),
+        # dd status=pr -> dd status=progress
+        (
+            CommandContext(args=(CommandArg("dd"),), arg_index=1, prefix="status=pr"),
+            {"progress"},
+            2,
+            True,
+        ),
+        # dd if=/et -> dd if=/etc/
+        (
+            CommandContext(args=(CommandArg("dd"),), arg_index=1, prefix="if=/et"),
+            {"/etc/"},
+            3,
+            False,
+        ),
+        # dd of=/dev/nul -> dd of=/dev/null
+        (
+            CommandContext(args=(CommandArg("dd"),), arg_index=1, prefix="of=/dev/nul"),
+            {"/dev/null"},
+            8,
+            True,
         ),
     ),
 )
-def test_equal_sign_arg(command_context, completions, lprefix):
+def test_equal_sign_arg(command_context, completions, lprefix, exp_append_space):
     bash_completions, bash_lprefix = complete_from_bash(
         CompletionContext(command_context)
     )
     assert bash_completions == completions and bash_lprefix == lprefix
     assert all(
-        isinstance(comp, RichCompletion) and not comp.append_space
+        isinstance(comp, RichCompletion) and comp.append_space == exp_append_space
         for comp in bash_completions
-    )  # there should not be an appended space after the equal sign
+    )