Repository: xonsh/xonsh

Issue:
fish-like partial suggestion completion
Xonsh already supports the fish-like suggestion completion, which is great. I.e., on a greyed suggestion, typing the right arrow completes with the full suggestion.

One thing I miss though is the fish partial suggestion completion. In fish, if I am right, when a suggestion is provided, typing "alt + right_arrow" completes the suggestion only until the next separator. Great to use parts of a suggestion only.

Any way a partial suggestion completion with alt + right_arrow is either already available, or could be added? :) .

Comments:

Patch:
diff --git a/docs/keyboard_shortcuts.rst b/docs/keyboard_shortcuts.rst
index 5131a273..45ef7401 100644
--- a/docs/keyboard_shortcuts.rst
+++ b/docs/keyboard_shortcuts.rst
@@ -31,4 +31,6 @@ Xonsh comes pre-baked with a few keyboard shortcuts. The following is only avail
       - Cut highlighted section
     * - Ctrl-V *[Beta]*
       - Paste clipboard contents
+    * - Ctrl-Right
+      - Complete a single auto-suggestion word
 
diff --git a/news/auto-suggest-word-alias.rst b/news/auto-suggest-word-alias.rst
new file mode 100644
index 00000000..045f4ea0
--- /dev/null
+++ b/news/auto-suggest-word-alias.rst
@@ -0,0 +1,23 @@
+**Added:**
+
+* Add ``CTRL-Right`` key binding to complete a single auto-suggestion word.
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* <news item>
+
+**Security:**
+
+* <news item>
diff --git a/news/fix-jedi-path-completion.rst b/news/fix-jedi-path-completion.rst
new file mode 100644
index 00000000..8757b89d
--- /dev/null
+++ b/news/fix-jedi-path-completion.rst
@@ -0,0 +1,23 @@
+**Added:**
+
+* <news item>
+
+**Changed:**
+
+* <news item>
+
+**Deprecated:**
+
+* <news item>
+
+**Removed:**
+
+* <news item>
+
+**Fixed:**
+
+* ``Jedi`` completer doesn't complete paths with ``~``.
+
+**Security:**
+
+* <news item>
diff --git a/xonsh/ptk_shell/key_bindings.py b/xonsh/ptk_shell/key_bindings.py
index 941c9d46..84598a44 100644
--- a/xonsh/ptk_shell/key_bindings.py
+++ b/xonsh/ptk_shell/key_bindings.py
@@ -208,9 +208,14 @@ def wrap_selection(buffer, left, right=None):
     buffer.selection_state = selection_state
 
 
-def load_xonsh_bindings() -> KeyBindingsBase:
+def load_xonsh_bindings(ptk_bindings: KeyBindingsBase) -> KeyBindingsBase:
     """
     Load custom key bindings.
+
+    Parameters
+    ----------
+    ptk_bindings :
+        The default prompt toolkit bindings. We need these to add aliases to them.
     """
     key_bindings = KeyBindings()
     handle = key_bindings.add
@@ -389,4 +394,12 @@ def load_xonsh_bindings() -> KeyBindingsBase:
             buff.cut_selection()
         get_by_name("yank").call(event)
 
+    def create_alias(new_keys, original_keys):
+        bindings = ptk_bindings.get_bindings_for_keys(tuple(original_keys))
+        for original_binding in bindings:
+            handle(*new_keys, filter=original_binding.filter)(original_binding.handler)
+
+    # Complete a single auto-suggestion word
+    create_alias([Keys.ControlRight], ["escape", "f"])
+
     return key_bindings
diff --git a/xonsh/ptk_shell/shell.py b/xonsh/ptk_shell/shell.py
index f61ea789..459c0bab 100644
--- a/xonsh/ptk_shell/shell.py
+++ b/xonsh/ptk_shell/shell.py
@@ -207,7 +207,8 @@ class PromptToolkitShell(BaseShell):
 
         self.prompt_formatter = PTKPromptFormatter(self.prompter)
         self.pt_completer = PromptToolkitCompleter(self.completer, self.ctx, self)
-        self.key_bindings = load_xonsh_bindings()
+        ptk_bindings = self.prompter.app.key_bindings
+        self.key_bindings = load_xonsh_bindings(ptk_bindings)
         self._overrides_deprecation_warning_shown = False
 
         # Store original `_history_matches` in case we need to restore it
diff --git a/xontrib/jedi.py b/xontrib/jedi.py
index 1d860b82..49d99138 100644
--- a/xontrib/jedi.py
+++ b/xontrib/jedi.py
@@ -65,8 +65,8 @@ def complete_jedi(context: CompletionContext):
 
     # if we're completing a possible command and the prefix contains a valid path, don't complete.
     if context.command:
-        path_parts = os.path.split(context.command.prefix)
-        if len(path_parts) > 1 and os.path.isdir(os.path.join(*path_parts[:-1])):
+        path_dir = os.path.dirname(context.command.prefix)
+        if path_dir and os.path.isdir(os.path.expanduser(path_dir)):
             return None
 
     filter_func = get_filter_function()


Test patch:
diff --git a/tests/xontribs/test_jedi.py b/tests/xontribs/test_jedi.py
index 0681e7fb..166ef200 100644
--- a/tests/xontribs/test_jedi.py
+++ b/tests/xontribs/test_jedi.py
@@ -253,6 +253,7 @@ def test_special_tokens(jedi_xontrib):
 @skip_if_on_windows
 def test_no_command_path_completion(jedi_xontrib, completion_context_parse):
     assert jedi_xontrib.complete_jedi(completion_context_parse("./", 2)) is None
+    assert jedi_xontrib.complete_jedi(completion_context_parse("~/", 2)) is None
     assert jedi_xontrib.complete_jedi(completion_context_parse("./e", 3)) is None
     assert jedi_xontrib.complete_jedi(completion_context_parse("/usr/bin/", 9)) is None
     assert (