Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions mycli/packages/filepaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ def list_path(root_dir: str) -> list[str]:
:return: list

"""
res = []
if os.path.isdir(root_dir):
for name in os.listdir(root_dir):
if os.path.isdir(name):
res.append(f'{name}/')
# if .sql is too restrictive it can be made configurable with some effort
elif name.lower().endswith('.sql'):
res.append(name)
return res
files = []
dirs = []
if not os.path.isdir(root_dir):
return []
for name in sorted(os.listdir(root_dir)):
if name.startswith('.'):
continue
elif os.path.isdir(name):
dirs.append(f'{name}/')
# if .sql is too restrictive it can be made configurable with some effort
elif name.lower().endswith('.sql'):
files.append(name)
return files + dirs


def complete_path(curr_dir: str, last_dir: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion mycli/sqlcompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ def find_files(self, word: str) -> Generator[Completion, None, None]:
"""
base_path, last_path, position = parse_path(word)
paths = suggest_path(word)
for name in sorted(paths):
for name in paths:
suggestion = complete_path(name, last_path)
if suggestion:
yield Completion(suggestion, position)
Expand Down
2 changes: 1 addition & 1 deletion test/test_smart_completion_public_schema_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,8 @@ def test_source_eager_completion(completer, complete_event):
error = 'unknown'
try:
assert [x.text for x in result] == [
'screenshots/',
script_filename,
'screenshots/',
]
except AssertionError as e:
success = False
Expand Down