Skip to content
Open
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
12 changes: 10 additions & 2 deletions src/kimi_cli/utils/file_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ def git_index_mtime(root: Path) -> float | None:
return None


def _parse_ls_files_output(stdout: str, *, filter_ignored: bool = True) -> list[str]:
def _parse_ls_files_output(stdout: str | None, *, filter_ignored: bool = True) -> list[str]:
"""Parse NUL-delimited ``git ls-files -z`` output into paths with synthesised dirs.

When *filter_ignored* is *True*, paths whose segments match
``is_ignored()`` are excluded so that tracked ``node_modules/``,
``vendor/``, etc. do not pollute completion candidates.
"""
if not stdout:
return []
paths: list[str] = []
seen_dirs: set[str] = set()
ignored_prefixes: set[str] = set()
Expand Down Expand Up @@ -193,9 +195,11 @@ def _git_deleted_files(root: Path, scope: str | None = None) -> set[str]:
cwd=root,
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=_GIT_LS_FILES_TIMEOUT,
)
if result.returncode == 0:
if result.returncode == 0 and result.stdout:
return {e for e in result.stdout.split("\0") if e}
except Exception:
pass
Expand Down Expand Up @@ -236,6 +240,8 @@ def list_files_git(
cwd=root,
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=_GIT_LS_FILES_TIMEOUT,
)
if result.returncode != 0:
Expand Down Expand Up @@ -265,6 +271,8 @@ def list_files_git(
cwd=root,
capture_output=True,
text=True,
encoding="utf-8",
errors="replace",
timeout=_GIT_LS_FILES_TIMEOUT,
)
if others.returncode == 0:
Expand Down
Loading