mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix mark occurrences on outdated offset while editing
This commit is contained in:
parent
e10f67a94a
commit
3ddfd62af8
2 changed files with 8 additions and 5 deletions
|
@ -356,6 +356,7 @@ public class MarkOccurrenceTest extends BaseUITestCase {
|
|||
}
|
||||
assertNotNull(fMatch);
|
||||
|
||||
fMatch= new Region(fMatch.getOffset(), fMatch.getLength() - 1);
|
||||
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||
|
||||
assertOccurrences(2);
|
||||
|
|
|
@ -3102,9 +3102,11 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
if (document == null)
|
||||
return;
|
||||
|
||||
final IRegion wordRegion= CWordFinder.findWord(document, selection.getOffset());
|
||||
if (wordRegion == null) {
|
||||
return;
|
||||
if (getSelectionProvider() instanceof ISelectionValidator) {
|
||||
ISelectionValidator validator= (ISelectionValidator)getSelectionProvider();
|
||||
if (!validator.isValid(selection)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasChanged= false;
|
||||
|
@ -3117,14 +3119,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
|
||||
return;
|
||||
}
|
||||
fMarkOccurrenceTargetRegion= wordRegion;
|
||||
fMarkOccurrenceTargetRegion= CWordFinder.findWord(document, offset);
|
||||
fMarkOccurrenceModificationStamp= currentModificationStamp;
|
||||
}
|
||||
|
||||
OccurrenceLocation[] locations= null;
|
||||
|
||||
IASTNodeSelector selector= astRoot.getNodeSelector(astRoot.getFilePath());
|
||||
IASTName name= selector.findEnclosingName(wordRegion.getOffset(), wordRegion.getLength());
|
||||
IASTName name= selector.findEnclosingName(selection.getOffset(), selection.getLength());
|
||||
|
||||
if (name != null) {
|
||||
IBinding binding= name.resolveBinding();
|
||||
|
|
Loading…
Add table
Reference in a new issue