diff --git a/src/solidlsp/language_servers/rust_analyzer.py b/src/solidlsp/language_servers/rust_analyzer.py index 2e222b5a8..cb059f693 100644 --- a/src/solidlsp/language_servers/rust_analyzer.py +++ b/src/solidlsp/language_servers/rust_analyzer.py @@ -210,6 +210,13 @@ def _create_dependency_provider(self) -> LanguageServerDependencyProvider: def is_ignored_dirname(self, dirname: str) -> bool: return super().is_ignored_dirname(dirname) or dirname in ["target"] + @override + def _get_published_diagnostics_wait_timeout(self, pull_diagnostics_failed: bool) -> float: + timeout = super()._get_published_diagnostics_wait_timeout(pull_diagnostics_failed) + # Rust diagnostics are often published asynchronously after the pull-diagnostics request, + # so keep a wider fallback wait window across all platforms. + return max(timeout, 8.0) + @staticmethod def _get_initialize_params(repository_absolute_path: str) -> InitializeParams: """ diff --git a/test/solidlsp/rust/test_rust_analyzer_detection.py b/test/solidlsp/rust/test_rust_analyzer_detection.py index fea2bb0e5..925fb11c7 100644 --- a/test/solidlsp/rust/test_rust_analyzer_detection.py +++ b/test/solidlsp/rust/test_rust_analyzer_detection.py @@ -518,6 +518,20 @@ def test_auto_install_success_but_binary_not_found_falls_through(self): assert "searched locations" in error_message.lower() # Should show what was checked +class TestRustAnalyzerDiagnosticsTimeout: + @pytest.mark.rust + @pytest.mark.parametrize("os_name", ["Windows", "Linux"]) + def test_all_platforms_use_longer_diagnostics_wait_timeout(self, os_name: str): + from solidlsp.language_servers.rust_analyzer import RustAnalyzer + + analyzer = RustAnalyzer.__new__(RustAnalyzer) + + with patch("solidlsp.language_servers.rust_analyzer.platform.system", return_value=os_name): + timeout = analyzer._get_published_diagnostics_wait_timeout(False) + + assert timeout >= 8.0 + + class TestRustAnalyzerDetectionIntegration: """ Integration tests that verify detection works on the current system.