From 3096ac4fe2567c11f3156bd65c51d4c435de3afd Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Wed, 1 Jul 2026 14:19:25 +0200 Subject: [PATCH] Fix in Project._is_ignored_relative_path: Filtering of files for source files ignored the language backend The check is really only possible for LSP, so the flag is now ignored for JetBrains (where there is no known list of languages). --- CHANGELOG.md | 2 ++ src/serena/project.py | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c12bb3ec..8a26a59a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ Status of the `main` branch. Changes prior to the next official version change w - Update prompts/instructions: Serena instructions manual, modes (editing, interactive) - Allow structured tool output to be configured on a per-context basis, disabling it for Claude Code (which does not correctly unpack structured output) #1042 + - Fix: Project-specific filtering of files for source files ignored the language backend. + The check is really only possible for LSP. * CLI: - Fix `--project-from-cwd` hijacking git worktrees nested under a Serena project. `find_project_root` diff --git a/src/serena/project.py b/src/serena/project.py index 87d0f969..8152a52a 100644 --- a/src/serena/project.py +++ b/src/serena/project.py @@ -231,17 +231,20 @@ class Project(ToStringMixin): log.debug(f"Path {abs_path} does not exist, skipping ignore check") return False - # Check file extension if it's a file - is_file = os.path.isfile(abs_path) - if is_file and ignore_non_source_files: - is_file_in_supported_language = False - for language in self.project_config.languages: - fn_matcher = language.get_source_fn_matcher() - if fn_matcher.is_relevant_filename(abs_path): - is_file_in_supported_language = True - break - if not is_file_in_supported_language: - return True + # check code file restriction (depending on backend) + if ignore_non_source_files: + # apply restriction only for LSP backend, which enumerates known languages + # and therefore can determine whether a file is a source file or not + if self.language_backend.is_lsp(): + if os.path.isfile(abs_path): + is_file_in_supported_language = False + for language in self.project_config.languages: + fn_matcher = language.get_source_fn_matcher() + if fn_matcher.is_relevant_filename(abs_path): + is_file_in_supported_language = True + break + if not is_file_in_supported_language: + return True # Create normalized path for consistent handling rel_path = Path(relative_path)