mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
Merge pull request #1897 from mitnk/fix-complete
Make readline completes to max prefix
This commit is contained in:
commit
a797a9d804
2 changed files with 21 additions and 3 deletions
14
news/quotes-paths.rst
Normal file
14
news/quotes-paths.rst
Normal file
|
@ -0,0 +1,14 @@
|
|||
**Added:** None
|
||||
|
||||
**Changed:**
|
||||
|
||||
* Quote all paths when completion if any of the paths needs be quoted,
|
||||
so that bash can automatically complete to the max prefix of the paths.
|
||||
|
||||
**Deprecated:** None
|
||||
|
||||
**Removed:** None
|
||||
|
||||
**Fixed:** None
|
||||
|
||||
**Security:** None
|
|
@ -134,12 +134,16 @@ def _quote_paths(paths, start, end):
|
|||
slash = xt.get_sep()
|
||||
orig_start = start
|
||||
orig_end = end
|
||||
# quote on all or none, to make readline completes to max prefix
|
||||
need_quotes = any(
|
||||
re.search(PATTERN_NEED_QUOTES, x) or
|
||||
(backslash in x and slash != backslash)
|
||||
for x in paths)
|
||||
|
||||
for s in paths:
|
||||
start = orig_start
|
||||
end = orig_end
|
||||
if (start == '' and
|
||||
(re.search(PATTERN_NEED_QUOTES, s) is not None or
|
||||
(backslash in s and slash != backslash))):
|
||||
if start == '' and need_quotes:
|
||||
start = end = _quote_to_use(s)
|
||||
if os.path.isdir(expand_path(s)):
|
||||
_tail = slash
|
||||
|
|
Loading…
Add table
Reference in a new issue