Skip to content

Fix ResourceItemLabelTest file-delete failure on Windows#4

Draft
Copilot wants to merge 1 commit into
masterfrom
copilot/fix-resource-item-label-delete-issue
Draft

Fix ResourceItemLabelTest file-delete failure on Windows#4
Copilot wants to merge 1 commit into
masterfrom
copilot/fix-resource-item-label-delete-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 30, 2026

On Windows, files cannot be deleted while open. testBug566858_leadingWhitespace calls getStyleRanges three times with the same filename (" test.txt"), and the original code attempted to delete the file immediately after dialog.close() — before the OS had released the file handle, causing a ResourceException.

Change

  • Removed file.delete(true, null) from after dialog.close()
  • Added a guarded delete at the start of getStyleRanges: if the file already exists (left over from a previous call), delete it there — by which point the prior dialog is fully torn down and the lock released
  • Final cleanup is handled by doTearDown, which deletes the whole project
// Before: delete immediately after close — fails on Windows if handle not yet released
dialog.close();
file.delete(true, null);  // ← boom on Windows

// After: delete at the start of the next call, when the prior dialog is gone
if (file.exists()) {
    file.delete(true, null);  // safe — previous dialog is fully closed
}
file.create(stream, true, new NullProgressMonitor());

Copilot AI changed the title [WIP] Fix ResourceItemLabelTest delete issue Fix ResourceItemLabelTest file-delete failure on Windows Mar 30, 2026
Copilot AI requested a review from fedejeanne March 30, 2026 12:19
@basilevs
Copy link
Copy Markdown

basilevs commented Mar 30, 2026

If the dialog leaks resources, should not it be fixed instead of relying on GC to close files? Why should test code adapted to a broken dialog?

@fedejeanne fedejeanne force-pushed the copilot/fix-resource-item-label-delete-issue branch from 8d8d72e to f830b3d Compare April 9, 2026 13:57
@fedejeanne
Copy link
Copy Markdown
Owner

@basilevs I don't see anything in FilteredResourcesSelectionDialog that could indicate any leaking files. Can you please elaborate on that?

@basilevs
Copy link
Copy Markdown

basilevs commented Apr 9, 2026

@basilevs I don't see anything in FilteredResourcesSelectionDialog that could indicate any leaking files. Can you please elaborate on that?

That was a comment to a previous revision, where deletion of a file was postponed to accommodate a broken dialog.

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.

ResourceItemLabelTest: Could not delete

3 participants