xmyshell 0.2.21__tar.gz → 0.2.22__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.21/xmyshell.egg-info → xmyshell-0.2.22}/PKG-INFO +1 -1
- {xmyshell-0.2.21 → xmyshell-0.2.22}/pyproject.toml +1 -1
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/completer.py +33 -21
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/keybindings.py +3 -3
- {xmyshell-0.2.21 → xmyshell-0.2.22/xmyshell.egg-info}/PKG-INFO +1 -1
- {xmyshell-0.2.21 → xmyshell-0.2.22}/LICENSE +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/README.md +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/setup.cfg +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/__init__.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/__main__.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/data/commands.json +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/environment.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/init.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/injection.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/kernel.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/main.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/meta.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/stubs/__init__.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/stubs/__init__.pyi +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/stubs/py.typed +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/themes.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/update.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell/utils.py +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell.egg-info/SOURCES.txt +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell.egg-info/dependency_links.txt +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell.egg-info/entry_points.txt +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell.egg-info/requires.txt +0 -0
- {xmyshell-0.2.21 → xmyshell-0.2.22}/xmyshell.egg-info/top_level.txt +0 -0
|
@@ -122,7 +122,7 @@ class ShellCompleter(Completer):
|
|
|
122
122
|
def _path_completions(self, text: str, max_results: int = 100, in_string: bool=False):
|
|
123
123
|
if text and text[-1] in whitespace: return
|
|
124
124
|
|
|
125
|
-
def last_token_raw(text: str) -> str:
|
|
125
|
+
def last_token_raw(text: str) -> tuple[str, bool]:
|
|
126
126
|
quote = None
|
|
127
127
|
start = 0
|
|
128
128
|
i = 0
|
|
@@ -141,26 +141,38 @@ class ShellCompleter(Completer):
|
|
|
141
141
|
elif ch == "\\":
|
|
142
142
|
i += 1
|
|
143
143
|
i += 1
|
|
144
|
-
return text[start:]
|
|
145
|
-
|
|
146
|
-
def
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
return text[start:], quote is not None
|
|
145
|
+
|
|
146
|
+
def split_lenient(s: str) -> list[str] | None:
|
|
147
|
+
try:
|
|
148
|
+
return shlex.split(s)
|
|
149
|
+
except ValueError:
|
|
150
|
+
pass
|
|
151
|
+
quote = None
|
|
152
|
+
i = 0
|
|
153
|
+
while i < len(s):
|
|
154
|
+
ch = s[i]
|
|
155
|
+
if quote:
|
|
156
|
+
if ch == quote: quote = None
|
|
157
|
+
elif ch == '\\' and quote == '"': i += 1
|
|
158
|
+
else:
|
|
159
|
+
if ch in ('"', "'"): quote = ch
|
|
160
|
+
elif ch == '\\': i += 1
|
|
161
|
+
i += 1
|
|
162
|
+
if quote:
|
|
163
|
+
try:
|
|
164
|
+
return shlex.split(s + quote)
|
|
165
|
+
except ValueError:
|
|
166
|
+
pass
|
|
167
|
+
return None
|
|
168
|
+
|
|
169
|
+
last, still_in = last_token_raw(text)
|
|
170
|
+
in_string = in_string or still_in
|
|
160
171
|
if last == '~': return # don't remove this
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
172
|
+
parts = split_lenient(last)
|
|
173
|
+
if parts:
|
|
174
|
+
path = os.path.expanduser(parts[0])
|
|
175
|
+
else:
|
|
164
176
|
path = os.path.expanduser(last)
|
|
165
177
|
dirname = os.path.dirname(path) or "."
|
|
166
178
|
prefix = os.path.basename(path).strip('"\'')
|
|
@@ -183,7 +195,7 @@ class ShellCompleter(Completer):
|
|
|
183
195
|
yield Completion(
|
|
184
196
|
name,
|
|
185
197
|
display=truncate(item, MAX_DISPLAY_LEN),
|
|
186
|
-
start_position
|
|
198
|
+
start_position=-len(prefix),
|
|
187
199
|
display_meta="directory" if is_dir else "file",
|
|
188
200
|
)
|
|
189
201
|
except OSError:
|
|
@@ -375,7 +375,7 @@ def _(event: KeyPressEvent) -> None:
|
|
|
375
375
|
buffer.insert_text(" ")
|
|
376
376
|
|
|
377
377
|
@bindings.add(Keys.Enter)
|
|
378
|
-
def
|
|
378
|
+
def _(event: KeyPressEvent):
|
|
379
379
|
buffer = event.current_buffer
|
|
380
380
|
current_line = buffer.document.current_line_before_cursor
|
|
381
381
|
|
|
@@ -386,6 +386,6 @@ def handle_enter(event):
|
|
|
386
386
|
else:
|
|
387
387
|
buffer.validate_and_handle()
|
|
388
388
|
|
|
389
|
-
@bindings.add(
|
|
390
|
-
def
|
|
389
|
+
@bindings.add(Keys.Escape, filter=has_completions, eager=True)
|
|
390
|
+
def _(event: KeyPressEvent):
|
|
391
391
|
event.current_buffer.cancel_completion()
|
|
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
|