diff --git a/src/serena/ls_manager.py b/src/serena/ls_manager.py index 27218ded..45405962 100644 --- a/src/serena/ls_manager.py +++ b/src/serena/ls_manager.py @@ -280,12 +280,17 @@ class LanguageServerFileChangeNotifier: Detects changes to source files on disk and notifies language servers of those changes. """ - def __init__(self, project: "Project", language_server_manager: LanguageServerManager) -> None: + def __init__(self, project: "Project", language_server_manager: LanguageServerManager, initial_poll: bool = True) -> None: self._project = project self._language_server_manager = language_server_manager self._freshness_last_seen_mtimes: dict[str, float] | None = None self._freshness_lock = threading.Lock() + if initial_poll: + # Establish the baseline for the first poll; no notifications are sent on the first call. + with LogTime("Initialising file change notifier (polling for baseline)"): + self.poll_and_notify() + def poll_and_notify(self) -> int: """ Detects source files that were changed, created or deleted on disk since the last call diff --git a/test/serena/test_ls_file_sync.py b/test/serena/test_ls_file_sync.py index feeacc8c..874dbcc7 100644 --- a/test/serena/test_ls_file_sync.py +++ b/test/serena/test_ls_file_sync.py @@ -132,13 +132,3 @@ def test_ls_low_level_find_references_with_explicit_sync(tmp_path): Tests that requesting references directly from the LS works if synchronisation is explicitly requested after external file changes. """ FileSystemSyncTestCase(use_serena_tool=False).run(tmp_path) - - -def test_sync_first_poll_is_baseline_only(tmp_path): - """A newly-loaded project must not report its entire pre-existing file set as changed.""" - repo_root = tmp_path / "repo" - shutil.copytree(get_repo_path(Language.PYTHON), repo_root) - with project_with_ls_context(Language.PYTHON, str(repo_root)) as project: - assert project.ls_sync_file_system_changes() == 0 - # No external edits between the two calls -> still nothing to report. - assert project.ls_sync_file_system_changes() == 0