Fix dead REPLACED check in the sample editor resource listener - #2415
Merged
Conversation
IResourceDelta.REPLACED is a delta flag, not a delta kind. getKind() only returns NO_CHANGE, ADDED, REMOVED, CHANGED, ADDED_PHANTOM or REMOVED_PHANTOM, so comparing it against REPLACED was always false and the editor never closed when its sample.properties input was replaced. Test REPLACED against getFlags() on a CHANGED delta instead, which is how ResourceComparator reports a resource that was deleted and recreated in the same operation.
vogella
force-pushed
the
sample-editor-replaced-flag
branch
from
August 9, 2026 07:29
11bf87f to
e5d962f
Compare
Contributor
Author
|
Nothing in this repo contributes to the samples extension point, there is no sample.properties anywhere in the tree, SampleWizard isn't even registered as a newWizard (it's only ever constructed programmatically by ShowSampleAction), and the update site it bootstraps from is a long-dead http:// URL. In practice the editor only appears if some external contributor still ships that extension point.# Still worth the fix, to guide users of this sample extension point. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SampleEditor.InputFileListenercloses the editor when itssample.propertiesinput goes away, but the replacement case never worked:IResourceDelta.REPLACEDis a delta flag, not a delta kind, sogetKind() == IResourceDelta.REPLACEDcould never be true.getKind()only ever returnsNO_CHANGE,ADDED,REMOVED,CHANGED,ADDED_PHANTOMorREMOVED_PHANTOM.The fix tests
REPLACEDagainstgetFlags()on aCHANGEDdelta, which is howResourceComparatoractually reports a resource that was deleted and recreated in the same operation. The removal case was already correct and is unchanged.This is the same class of bug as the one fixed for
TargetEditorin #2414, found while reviewing it.