mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 00:41:00 +01:00
Merge pull request #1751 from blahgeek/fix-complete-alias
fix completion after alias expansion in prompt_toolkit
This commit is contained in:
commit
2c4096c596
2 changed files with 22 additions and 5 deletions
13
news/fix-complete-alias.rst
Normal file
13
news/fix-complete-alias.rst
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
**Added:** None
|
||||||
|
|
||||||
|
**Changed:** None
|
||||||
|
|
||||||
|
**Deprecated:** None
|
||||||
|
|
||||||
|
**Removed:** None
|
||||||
|
|
||||||
|
**Fixed:**
|
||||||
|
|
||||||
|
* Fix completion after alias expansion
|
||||||
|
|
||||||
|
**Security:** None
|
|
@ -27,14 +27,18 @@ class PromptToolkitCompleter(Completer):
|
||||||
yield from []
|
yield from []
|
||||||
else:
|
else:
|
||||||
line = document.current_line.lstrip()
|
line = document.current_line.lstrip()
|
||||||
|
line_ex = builtins.aliases.expand_alias(line)
|
||||||
|
|
||||||
endidx = document.cursor_position_col
|
endidx = document.cursor_position_col
|
||||||
begidx = line[:endidx].rfind(' ') + 1 if line[:endidx].rfind(' ') >= 0 else 0
|
begidx = (line[:endidx].rfind(' ') + 1
|
||||||
|
if line[:endidx].rfind(' ') >= 0 else 0)
|
||||||
prefix = line[begidx:endidx]
|
prefix = line[begidx:endidx]
|
||||||
line = builtins.aliases.expand_alias(line)
|
expand_offset = len(line_ex) - len(line)
|
||||||
|
|
||||||
completions, l = self.completer.complete(prefix,
|
completions, l = self.completer.complete(prefix,
|
||||||
line,
|
line_ex,
|
||||||
begidx,
|
begidx + expand_offset,
|
||||||
endidx,
|
endidx + expand_offset,
|
||||||
self.ctx)
|
self.ctx)
|
||||||
if len(completions) <= 1:
|
if len(completions) <= 1:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue