diff --git a/lib/esbonio/changes/925.fix.md b/lib/esbonio/changes/925.fix.md new file mode 100644 index 000000000..7c39d2088 --- /dev/null +++ b/lib/esbonio/changes/925.fix.md @@ -0,0 +1 @@ +The sphinx agent should now be able to collect diagnostics from extensions that make use of the `build-finished` event e.g. sphinx-needs by @AlexanderLanin diff --git a/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py b/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py index a18ab00a1..1a80a4780 100644 --- a/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py +++ b/lib/esbonio/esbonio/sphinx_agent/handlers/diagnostics.py @@ -45,4 +45,8 @@ def setup(app: Sphinx): # TODO: Support for Sphinx v7+ # app.connect("include-read") - app.connect("build-finished", sync_diagnostics) + # sync_diagnostics needs to run after all diagnostics have been emitted. + # This ensures proper synchronization of data, as some extensions, like + # sphinx-needs, emit diagnostics during the "build-finished" event. + # Setting priority to 900 ensures this handler runs after typical operations. + app.connect("build-finished", sync_diagnostics, priority=900)