xmyshell 0.2.25__tar.gz → 0.2.26__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xmyshell-0.2.25/xmyshell.egg-info → xmyshell-0.2.26}/PKG-INFO +1 -1
- {xmyshell-0.2.25 → xmyshell-0.2.26}/pyproject.toml +1 -1
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/completer.py +20 -10
- {xmyshell-0.2.25 → xmyshell-0.2.26/xmyshell.egg-info}/PKG-INFO +1 -1
- {xmyshell-0.2.25 → xmyshell-0.2.26}/LICENSE +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/README.md +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/setup.cfg +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/__init__.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/__main__.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/data/commands.json +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/environment.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/init.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/injection.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/kernel.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/keybindings.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/main.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/meta.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/__init__.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/__init__.pyi +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/py.typed +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/themes.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/update.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/utils.py +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/SOURCES.txt +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/dependency_links.txt +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/entry_points.txt +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/requires.txt +0 -0
- {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/top_level.txt +0 -0
|
@@ -146,6 +146,10 @@ class ShellCompleter(Completer):
|
|
|
146
146
|
def _path_completions(self, text: str, max_results: int = 100, in_string: bool=False):
|
|
147
147
|
if text and text[-1] in whitespace: return
|
|
148
148
|
|
|
149
|
+
# On Windows a backslash is a path separator (`C:\Users\me`), not an
|
|
150
|
+
# escape character, so it must never consume the following character.
|
|
151
|
+
escape = os.name != "nt"
|
|
152
|
+
|
|
149
153
|
def last_token_raw(text: str) -> tuple[str, bool]:
|
|
150
154
|
quote = None
|
|
151
155
|
start = 0
|
|
@@ -155,21 +159,21 @@ class ShellCompleter(Completer):
|
|
|
155
159
|
if quote:
|
|
156
160
|
if ch == quote:
|
|
157
161
|
quote = None
|
|
158
|
-
elif ch == "\\" and quote == '"':
|
|
162
|
+
elif ch == "\\" and quote == '"' and escape:
|
|
159
163
|
i += 1
|
|
160
164
|
else:
|
|
161
165
|
if ch in ("'", '"'):
|
|
162
166
|
quote = ch
|
|
163
167
|
elif ch in " \t":
|
|
164
168
|
start = i + 1
|
|
165
|
-
elif ch == "\\":
|
|
169
|
+
elif ch == "\\" and escape:
|
|
166
170
|
i += 1
|
|
167
171
|
i += 1
|
|
168
172
|
return text[start:], quote is not None
|
|
169
173
|
|
|
170
174
|
def split_lenient(s: str) -> list[str] | None:
|
|
171
175
|
try:
|
|
172
|
-
return shlex.split(s)
|
|
176
|
+
return shlex.split(s, posix=escape)
|
|
173
177
|
except ValueError:
|
|
174
178
|
pass
|
|
175
179
|
quote = None
|
|
@@ -178,14 +182,14 @@ class ShellCompleter(Completer):
|
|
|
178
182
|
ch = s[i]
|
|
179
183
|
if quote:
|
|
180
184
|
if ch == quote: quote = None
|
|
181
|
-
elif ch == '\\' and quote == '"': i += 1
|
|
185
|
+
elif ch == '\\' and quote == '"' and escape: i += 1
|
|
182
186
|
else:
|
|
183
187
|
if ch in ('"', "'"): quote = ch
|
|
184
|
-
elif ch == '\\': i += 1
|
|
188
|
+
elif ch == '\\' and escape: i += 1
|
|
185
189
|
i += 1
|
|
186
190
|
if quote:
|
|
187
191
|
try:
|
|
188
|
-
return shlex.split(s + quote)
|
|
192
|
+
return shlex.split(s + quote, posix=escape)
|
|
189
193
|
except ValueError:
|
|
190
194
|
pass
|
|
191
195
|
return None
|
|
@@ -195,19 +199,25 @@ class ShellCompleter(Completer):
|
|
|
195
199
|
if last == '~': return # don't remove this
|
|
196
200
|
parts = split_lenient(last)
|
|
197
201
|
if parts:
|
|
198
|
-
|
|
202
|
+
token = parts[0]
|
|
203
|
+
# With posix=False quotes are kept verbatim ('"a dir"'): drop the
|
|
204
|
+
# surrounding pair so the quoted path resolves on disk.
|
|
205
|
+
if not escape and len(token) >= 2 and token[0] == token[-1] and token[0] in ('"', "'"):
|
|
206
|
+
token = token[1:-1]
|
|
207
|
+
path = os.path.expanduser(token)
|
|
199
208
|
else:
|
|
200
209
|
path = os.path.expanduser(last)
|
|
201
210
|
dirname = os.path.dirname(path) or "."
|
|
202
|
-
prefix = os.path.basename(path).strip('"\'')
|
|
211
|
+
prefix = os.path.basename(path).strip('"\'').lower()
|
|
203
212
|
|
|
204
213
|
try:
|
|
205
214
|
entries = sorted(os.listdir(dirname))
|
|
206
215
|
except OSError:
|
|
207
216
|
return
|
|
208
217
|
|
|
209
|
-
exact = [e for e in entries if e.startswith(prefix)]
|
|
210
|
-
|
|
218
|
+
exact = [e for e in entries if e.lower().startswith(prefix)]
|
|
219
|
+
exact_set = set(exact)
|
|
220
|
+
fuzzy = [e for e in entries if not e in exact_set and prefix in e.lower()]
|
|
211
221
|
|
|
212
222
|
budget = max_results - len(exact[:max_results])
|
|
213
223
|
selected = exact[:max_results] + fuzzy[:max(0, budget)]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|