Initialise file change notifier (establishing baseline) upon construction

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-07-21 13:10:21 +02:00
1 parent ba7cdffc02
commit 574110fc28
2 files changed
+6 -11

No files matched your search

+6 -1
View File
@@ -280,12 +280,17 @@ class LanguageServerFileChangeNotifier:
Detects changes to source files on disk and notifies language servers of those changes. 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._project = project
self._language_server_manager = language_server_manager self._language_server_manager = language_server_manager
self._freshness_last_seen_mtimes: dict[str, float] | None = None self._freshness_last_seen_mtimes: dict[str, float] | None = None
self._freshness_lock = threading.Lock() 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: def poll_and_notify(self) -> int:
""" """
Detects source files that were changed, created or deleted on disk since the last call Detects source files that were changed, created or deleted on disk since the last call
-10
View File
@@ -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. 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) 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