xmyshell 0.2.6__tar.gz → 0.2.8__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.
Files changed (25) hide show
  1. {xmyshell-0.2.6/xmyshell.egg-info → xmyshell-0.2.8}/PKG-INFO +1 -1
  2. {xmyshell-0.2.6 → xmyshell-0.2.8}/pyproject.toml +1 -1
  3. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/completer.py +46 -2
  4. {xmyshell-0.2.6 → xmyshell-0.2.8/xmyshell.egg-info}/PKG-INFO +1 -1
  5. {xmyshell-0.2.6 → xmyshell-0.2.8}/LICENSE +0 -0
  6. {xmyshell-0.2.6 → xmyshell-0.2.8}/README.md +0 -0
  7. {xmyshell-0.2.6 → xmyshell-0.2.8}/setup.cfg +0 -0
  8. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/__init__.py +0 -0
  9. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/__main__.py +0 -0
  10. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/data/commands.json +0 -0
  11. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/environment.py +0 -0
  12. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/init.py +0 -0
  13. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/kernel.py +0 -0
  14. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/keybindings.py +0 -0
  15. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/lexer.py +0 -0
  16. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/main.py +0 -0
  17. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/meta.py +0 -0
  18. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/themes.py +0 -0
  19. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/update.py +0 -0
  20. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell/utils.py +0 -0
  21. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell.egg-info/SOURCES.txt +0 -0
  22. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell.egg-info/dependency_links.txt +0 -0
  23. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell.egg-info/entry_points.txt +0 -0
  24. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell.egg-info/requires.txt +0 -0
  25. {xmyshell-0.2.6 → xmyshell-0.2.8}/xmyshell.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xmyshell
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xmyshell"
3
- version = "0.2.6"
3
+ version = "0.2.8"
4
4
  description = "XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -134,7 +134,7 @@ class ShellCompleter(Completer):
134
134
  if len(matches) >= max_results:
135
135
  break
136
136
 
137
- for item in matches:
137
+ for item in sorted(matches):
138
138
  full = os.path.join(dirname, item)
139
139
  is_dir = os.path.isdir(full)
140
140
  name = item + ("/" if is_dir else "")
@@ -172,6 +172,44 @@ class ShellCompleter(Completer):
172
172
  )
173
173
 
174
174
  def _python_completion(self, text: str):
175
+
176
+ def _in_string(text: str) -> str | None:
177
+ i, n = 0, len(text)
178
+ quote = ''
179
+ content_start = 0
180
+
181
+ while i < n:
182
+ c = text[i]
183
+ if not quote:
184
+ if c in ('"', "'"):
185
+ if text[i:i+3] in ('"""', "'''"):
186
+ quote = text[i:i+3]
187
+ i += 3
188
+ else:
189
+ quote = c
190
+ i += 1
191
+ content_start = i
192
+ continue
193
+ i += 1
194
+ else:
195
+ if c == '\\':
196
+ i += 2
197
+ continue
198
+ if text.startswith(quote, i):
199
+ i += len(quote)
200
+ quote = ''
201
+ continue
202
+ i += 1
203
+
204
+ if not quote:
205
+ return None
206
+ return text[content_start:]
207
+
208
+ string = _in_string(text)
209
+ if string:
210
+ yield from self._path_completions(string)
211
+ return
212
+
175
213
  if text and text[-1].isspace():
176
214
  return
177
215
  last_token = text.split()[-1] if text.split() else ''
@@ -425,7 +463,13 @@ class ShellCompleter(Completer):
425
463
  # filter (which hides completions identical to the replaced text) and
426
464
  # doubles as the shell argument separator. Invisible characters would
427
465
  # also bypass the filter, but would corrupt command parsing.
428
- completions[0].text = completions[0].text + " "
466
+ completion = completions[0]
467
+ text_before_cursor = document.text_before_cursor
468
+ replaced_text = text_before_cursor[
469
+ len(text_before_cursor) + completion.start_position :
470
+ ]
471
+ if replaced_text == completion.text:
472
+ completion.text = completion.text + " "
429
473
  return completions
430
474
 
431
475
  def completer_init() -> None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xmyshell
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: XmyShell is a shell-like tool built on top of prompt_toolkit which provides a persistent Python runtime.
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
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