mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
aliases: fix expand_alias (#5598)
* fix * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: a <1@1.1> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
03499cb263
commit
38e9397f38
2 changed files with 11 additions and 1 deletions
|
@ -107,6 +107,16 @@ def test_recursive_callable_partial_handles(xession):
|
|||
assert obs == exp
|
||||
|
||||
|
||||
def test_expand_alias():
|
||||
ales = Aliases()
|
||||
ales["ls"] = ["ls", "-G"]
|
||||
ales["ff"] = lambda args: print(args)
|
||||
exp_ls = ales.expand_alias("ls ", 3)
|
||||
exp_ff = ales.expand_alias("ff ", 3)
|
||||
assert exp_ls == "ls -G "
|
||||
assert exp_ff == "ff "
|
||||
|
||||
|
||||
def _return_to_sender_none():
|
||||
return "wakka", {}
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ class Aliases(cabc.MutableMapping):
|
|||
The command won't be expanded if the cursor's inside/behind it.
|
||||
"""
|
||||
word = (line.split(maxsplit=1) or [""])[0]
|
||||
if word in XSH.aliases and isinstance(self.get(word), cabc.Sequence): # type: ignore
|
||||
if word in self and not callable(self.get(word)[0]): # type: ignore
|
||||
word_idx = line.find(word)
|
||||
word_edge = word_idx + len(word)
|
||||
if cursor_index > word_edge:
|
||||
|
|
Loading…
Add table
Reference in a new issue