Skip to content

Commit

Permalink
prompt: only allow file completion at well-defined points
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanePrawn committed Oct 6, 2023
1 parent 77943fc commit 6367a18
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion babi/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ def _tab(self) -> None:
self._complete_file()

def _complete_file(self) -> None:
# only allow completion at the end of the prompt or before a separator
if self._x != len(self._s) and self._s[self._x] not in ("/", " "):
return
partial = self._s[:self._x]
completions = glob.glob(partial + '*')
completions = glob.glob(f'{partial}*')
if not completions:
return
common = os.path.commonprefix(completions)
Expand Down

0 comments on commit 6367a18

Please sign in to comment.