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.
Files changed (28) hide show
  1. {xmyshell-0.2.25/xmyshell.egg-info → xmyshell-0.2.26}/PKG-INFO +1 -1
  2. {xmyshell-0.2.25 → xmyshell-0.2.26}/pyproject.toml +1 -1
  3. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/completer.py +20 -10
  4. {xmyshell-0.2.25 → xmyshell-0.2.26/xmyshell.egg-info}/PKG-INFO +1 -1
  5. {xmyshell-0.2.25 → xmyshell-0.2.26}/LICENSE +0 -0
  6. {xmyshell-0.2.25 → xmyshell-0.2.26}/README.md +0 -0
  7. {xmyshell-0.2.25 → xmyshell-0.2.26}/setup.cfg +0 -0
  8. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/__init__.py +0 -0
  9. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/__main__.py +0 -0
  10. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/data/commands.json +0 -0
  11. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/environment.py +0 -0
  12. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/init.py +0 -0
  13. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/injection.py +0 -0
  14. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/kernel.py +0 -0
  15. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/keybindings.py +0 -0
  16. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/main.py +0 -0
  17. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/meta.py +0 -0
  18. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/__init__.py +0 -0
  19. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/__init__.pyi +0 -0
  20. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/stubs/py.typed +0 -0
  21. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/themes.py +0 -0
  22. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/update.py +0 -0
  23. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell/utils.py +0 -0
  24. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/SOURCES.txt +0 -0
  25. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/dependency_links.txt +0 -0
  26. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/entry_points.txt +0 -0
  27. {xmyshell-0.2.25 → xmyshell-0.2.26}/xmyshell.egg-info/requires.txt +0 -0
  28. {xmyshell-0.2.25 → xmyshell-0.2.26}/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.25
3
+ Version: 0.2.26
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.25"
3
+ version = "0.2.26"
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"
@@ -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
- path = os.path.expanduser(parts[0])
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
- fuzzy = [e for e in entries if not e.startswith(prefix) and prefix in e]
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)]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xmyshell
3
- Version: 0.2.25
3
+ Version: 0.2.26
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