diff --git a/mycli/packages/filepaths.py b/mycli/packages/filepaths.py index 19368050..5d67582c 100644 --- a/mycli/packages/filepaths.py +++ b/mycli/packages/filepaths.py @@ -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: diff --git a/mycli/sqlcompleter.py b/mycli/sqlcompleter.py index 1b6c0e06..187c323b 100644 --- a/mycli/sqlcompleter.py +++ b/mycli/sqlcompleter.py @@ -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) diff --git a/test/test_smart_completion_public_schema_only.py b/test/test_smart_completion_public_schema_only.py index b9c7b9fc..42769d96 100644 --- a/test/test_smart_completion_public_schema_only.py +++ b/test/test_smart_completion_public_schema_only.py @@ -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