Skip to content

Do not wait for a running build to validate the state of a writable file - #4582

Open
RoiSoleil wants to merge 1 commit into
eclipse-platform:masterfrom
RoiSoleil:validate-state-without-rule
Open

RoiSoleil wants to merge 1 commit into
eclipse-platform:masterfrom
RoiSoleil:validate-state-without-rule

Conversation

@RoiSoleil

@RoiSoleil RoiSoleil commented Nov 19, 2026 •

Copy link
Copy Markdown

Fixes #4581

What: TextFileDocumentProvider.validateState() validates the file buffer directly, without a workspace operation, when computeValidateStateRule() is null, that is, when the file is not read-only. Read-only files keep the workspace operation, its rule and the cancellable dialog from Bug 546828.

Why: For a writable file, ResourceFileBuffer.validateState() does not call IWorkspace.validateEdit(), so nothing needs a rule. The file rule used until now only made the first keystroke in a non-dirty editor wait for a running build.

Tests: A new test checks that a writable file is validated while another job holds the workspace rule and lock. It fails without the fix. The existing test now uses a read-only file, so it still covers the operation path.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GviovNL1A9qQNNC72f312S

TextFileDocumentProvider.validateState() ran the validation as a
workspace operation whose scheduling rule falls back to the file when
IResourceRuleFactory.validateEditRule() returns null (Bug 546828). That
rule conflicts with the workspace root rule held by a build, so the
first keystroke in a non-dirty editor blocked the UI thread until the
build ended, with only a "User Operation is Waiting" dialog.

validateEditRule() returns null when the file is not read-only, and for
such a file ResourceFileBuffer.validateState() does not call
IWorkspace.validateEdit(): there is nothing to protect with a rule. The
file buffer is now validated directly in that case. Read-only files keep
the workspace operation, its rule and the cancellable dialog.

The existing test now uses a read-only file, so it still covers the
operation path, and a new test checks that a writable file is validated
while another job holds the workspace lock.

Fixes eclipse-platform#4581

Signed-off-by: Hélios GILLES <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GviovNL1A9qQNNC72f312S

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change to avoid workspace-lock waits during writable-file validation.

No open issues 🎉

What changed in this PR

Addresses #4581 by avoiding workspace-lock waits when validating writable files in text editors, allowing the first keystroke to proceed during a build.

Changes:

  • Validates the file buffer directly when no scheduling rule is required, while preserving workspace-operation handling for read-only files.
  • Adds a writable-file regression test and updates the existing lock-wait test to use a read-only file.
File Description
tests/​org.eclipse.ui.editors.tests/​src/​org/​eclipse/​ui/​editors/​tests/​TextFileDocumentProviderTest.java Tests nonblocking writable-file validation and preserves read-only lock-wait coverage.
bundles/​org.eclipse.ui.editors/​src/​org/​eclipse/​ui/​editors/​text/​TextFileDocumentProvider.java Bypasses the workspace operation when file-buffer validation requires no rule.

Review effort: Balanced

@laeubi

laeubi commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Just as a note, if a file is writable can be change during a build (e.g. it is opens and windows does not allows concurrent access, a build step deletes the file, ...) - the PR description reads a bit lengthy and it might help to make it more focused on what and why is changed.

@RoiSoleil

Copy link
Copy Markdown
Author

Thanks, I shortened the description.

The writable state can indeed change at any time, but the change does not rely on it staying stable:

  • ResourceFileBuffer.validateState() checks isReadOnly() again itself. A file that became read-only in between still goes through IWorkspace.validateEdit().
  • The previous code had the same window: the rule was computed before the operation ran, and for a file that was writable at that moment it was the file itself, not the parent rule that a read-only file needs.
  • If a build step deletes the file, or another process locks it (on Windows, this does not change the read-only attribute), isReadOnly() is false. The buffer then only checks the derived flag and fires its state events, without touching the workspace. Inside the operation it did the same, after waiting for the build.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   867 files  ±0     867 suites  ±0   47m 3s ⏱️ - 3m 56s
 8 549 tests +1   8 309 ✅ +1  240 💤 ±0  0 ❌ ±0 
21 519 runs  +3  20 846 ✅ +3  673 💤 ±0  0 ❌ ±0 

Results for commit 180c25b. ± Comparison against base commit b5dd338.

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.

First keystroke in a text editor waits for a running build although validateEditRule() says no rule is needed

3 participants