Skip to content

Skip organize imports on save while the type indexer is busy#3058

Open
vogella wants to merge 1 commit into
eclipse-jdt:masterfrom
vogella:organize-imports-skip-indexer-busy
Open

Skip organize imports on save while the type indexer is busy#3058
vogella wants to merge 1 commit into
eclipse-jdt:masterfrom
vogella:organize-imports-skip-indexer-busy

Conversation

@vogella

@vogella vogella commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

When Organize Imports is enabled as a save action, resolving missing imports searches the type index with WAIT_UNTIL_READY_TO_SEARCH. Saving right after startup, a branch switch or a large build therefore blocks until indexing finishes, which regularly exceeds the 2 second threshold and greets the user with the "Slow Save Actions" warning dialog.

This adds OrganizeImportsOperation#setSkipWhenIndexerBusy, which makes the type search use CANCEL_IF_NOT_READY_TO_SEARCH and produce no edit while the indexer is busy. The save actions enable it, so saving stays fast and a missing import is simply added on the next save once the index is ready. The Clean Up wizard and the manual Organize Imports action are unchanged and still wait for the index.

When Organize Imports runs as a save action, resolving missing imports
uses SearchEngine.searchAllTypeNames with WAIT_UNTIL_READY_TO_SEARCH.
Right after startup, a branch switch or a large build this blocks the
save until indexing finishes, which regularly exceeds the 2s threshold
and triggers the 'Slow Save Actions' warning dialog.

OrganizeImportsOperation gets a new API setSkipWhenIndexerBusy. When
enabled, the type search uses CANCEL_IF_NOT_READY_TO_SEARCH and the
operation creates no edit while the indexer is busy instead of waiting.
CleanUpPostSaveListener enables this for the save actions, so a save
never waits for the index; a missing import is added on the next save
once the index is ready. The Clean Up wizard and the manual Organize
Imports action keep waiting as before.
@vogella

vogella commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

This happens all the time at my current client:

image

@vogella vogella marked this pull request as ready for review July 2, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant