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);
|
assertNotNull(fMatch);
|
||||||
|
|
||||||
|
fMatch= new Region(fMatch.getOffset(), fMatch.getLength() - 1);
|
||||||
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
fEditor.selectAndReveal(fMatch.getOffset(), fMatch.getLength());
|
||||||
|
|
||||||
assertOccurrences(2);
|
assertOccurrences(2);
|
||||||
|
|
|
@ -3102,10 +3102,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
if (document == null)
|
if (document == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final IRegion wordRegion= CWordFinder.findWord(document, selection.getOffset());
|
if (getSelectionProvider() instanceof ISelectionValidator) {
|
||||||
if (wordRegion == null) {
|
ISelectionValidator validator= (ISelectionValidator)getSelectionProvider();
|
||||||
|
if (!validator.isValid(selection)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
boolean hasChanged= false;
|
boolean hasChanged= false;
|
||||||
if (document instanceof IDocumentExtension4) {
|
if (document instanceof IDocumentExtension4) {
|
||||||
|
@ -3117,14 +3119,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
|
if (markOccurrenceTargetRegion.getOffset() <= offset && offset <= markOccurrenceTargetRegion.getOffset() + markOccurrenceTargetRegion.getLength())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fMarkOccurrenceTargetRegion= wordRegion;
|
fMarkOccurrenceTargetRegion= CWordFinder.findWord(document, offset);
|
||||||
fMarkOccurrenceModificationStamp= currentModificationStamp;
|
fMarkOccurrenceModificationStamp= currentModificationStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
OccurrenceLocation[] locations= null;
|
OccurrenceLocation[] locations= null;
|
||||||
|
|
||||||
IASTNodeSelector selector= astRoot.getNodeSelector(astRoot.getFilePath());
|
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) {
|
if (name != null) {
|
||||||
IBinding binding= name.resolveBinding();
|
IBinding binding= name.resolveBinding();
|
||||||
|
|
Loading…
Add table
Reference in a new issue