Skip to content

Commit 32ebcb3

Browse files
Merge branch 'master' into master
2 parents b013b4e + d390a10 commit 32ebcb3

2 files changed

Lines changed: 41 additions & 11 deletions

File tree

bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ private void expandProjectionAnnotationsBorderingRegion(Region region) throws Ba
793793
for (Iterator<Annotation> it= fProjectionAnnotationModel.getAnnotationIterator(); it.hasNext();) {
794794
Annotation annotation= it.next();
795795
Position position= fProjectionAnnotationModel.getPosition(annotation);
796-
if (bordersOrSurroundsRegion(position, region)) {
796+
if (position != null && bordersOrSurroundsRegion(position, region)) {
797797
fProjectionAnnotationModel.expand(annotation);
798798
}
799799
}
@@ -808,7 +808,7 @@ private void hideProjectionAnnotationsOutsideOfVisibleRegion() throws BadLocatio
808808

809809
private void hideProjectionAnnotationIfPartsAreOutsideOfVisibleRegion(Annotation annotation) throws BadLocationException {
810810
Position position= fProjectionAnnotationModel.getPosition(annotation);
811-
if (annotation instanceof ProjectionAnnotation a) {
811+
if (annotation instanceof ProjectionAnnotation a && position != null) {
812812
if (overlapsWithNonVisibleRegions(position.getOffset(), position.getLength())) {
813813
a.setHidden(true);
814814
} else {
@@ -1355,6 +1355,9 @@ public IRegion computeCollapsedRegion(Position position) {
13551355
* @since 3.1
13561356
*/
13571357
IRegion[] computeCollapsedRegions(Position position) {
1358+
if (position == null) {
1359+
return null;
1360+
}
13581361
try {
13591362
IDocument document= getDocument();
13601363
if (document == null) {

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/quickaccess/QuickAccessContents.java

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ private int computeNumberOfItems() {
147147
* @param filter The filter text to apply to results
148148
*/
149149
public void updateProposals(String filter) {
150+
if (Policy.DEBUG_QUICK_ACCESS) {
151+
trace("Updating proposals with filter: \"" + filter + "\""); //$NON-NLS-1$ //$NON-NLS-2$
152+
}
150153
if (computeProposalsJob != null) {
151154
computeProposalsJob.cancel();
152155
computeProposalsJob = null;
@@ -165,12 +168,15 @@ public void updateProposals(String filter) {
165168
final Job currentComputeEntriesJob = Job.create(computingMessage, theMonitor -> {
166169
entries.set(
167170
computeMatchingEntries(filter, perfectMatch, maxNumberOfItemsInTable, theMonitor));
168-
Tracing.printTrace(QuickAccessContents.class.getName(),
169-
"[" + Thread.currentThread() + "] Computed entries: " + //$NON-NLS-1$ //$NON-NLS-2$
170-
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId()).toList());
171+
if (Policy.DEBUG_QUICK_ACCESS) {
172+
trace("Computed entries: " + toIds(entries)); //$NON-NLS-1$
173+
}
171174
return theMonitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
172175
});
173176
currentComputeEntriesJob.setPriority(Job.INTERACTIVE);
177+
if (Policy.DEBUG_QUICK_ACCESS) {
178+
trace("Will compute proposals with Job: " + currentComputeEntriesJob); //$NON-NLS-1$
179+
}
174180
// feedback is delayed in a job as we don't want to show it on every keystroke
175181
// but only when user seems to be waiting
176182
UIJob computingFeedbackJob = new UIJob(table.getDisplay(), QuickAccessMessages.QuickAccessContents_computeMatchingEntries_displayFeedback_jobName) {
@@ -186,16 +192,17 @@ public IStatus runInUIThread(IProgressMonitor monitor) {
186192
currentComputeEntriesJob.addJobChangeListener(new JobChangeAdapter() {
187193
@Override
188194
public void done(IJobChangeEvent event) {
189-
Tracing.printTrace(QuickAccessContents.class.getName(),
190-
"[" + Thread.currentThread() + "] Compute entries Job result: " + event.getResult()); //$NON-NLS-1$ //$NON-NLS-2$
195+
if (Policy.DEBUG_QUICK_ACCESS) {
196+
trace("Compute entries Job result: " + event.getResult() + //$NON-NLS-1$
197+
", Job: " + currentComputeEntriesJob + //$NON-NLS-1$
198+
", last proposals Job: " + computeProposalsJob + //$NON-NLS-1$
199+
", entries: " + toIds(entries)); //$NON-NLS-1$
200+
}
191201
computingFeedbackJob.cancel();
192202
if (computeProposalsJob == currentComputeEntriesJob && event.getResult().isOK()
193203
&& !table.isDisposed()) {
194204
if (Policy.DEBUG_QUICK_ACCESS) {
195-
Tracing.printTrace(QuickAccessContents.class.getName(),
196-
"[" + Thread.currentThread() + "] Setting quick access contents: " + //$NON-NLS-1$ //$NON-NLS-2$
197-
Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId())
198-
.toList());
205+
trace("Setting quick access contents: " + toIds(entries)); //$NON-NLS-1$
199206
}
200207
display.asyncExec(() -> {
201208
computingFeedbackJob.cancel();
@@ -205,6 +212,9 @@ public void done(IJobChangeEvent event) {
205212
}
206213
});
207214
this.computeProposalsJob = currentComputeEntriesJob;
215+
if (Policy.DEBUG_QUICK_ACCESS) {
216+
trace("Set last proposals Job: " + computeProposalsJob); //$NON-NLS-1$
217+
}
208218
currentComputeEntriesJob.schedule();
209219
computingFeedbackJob.schedule(200); // delay a bit so if proposals compute fast enough, we don't show feedback
210220
}
@@ -239,6 +249,9 @@ public void setShowAllMatches(boolean showAll) {
239249
if (showAllMatches != showAll) {
240250
showAllMatches = showAll;
241251
updateInfoLabel();
252+
if (Policy.DEBUG_QUICK_ACCESS) {
253+
trace("setShowAllMatches triggering proposals update"); //$NON-NLS-1$
254+
}
242255
updateProposals(filterText.getText().toLowerCase());
243256
}
244257
}
@@ -689,6 +702,9 @@ public void keyReleased(KeyEvent e) {
689702
});
690703
filterText.addModifyListener(e -> {
691704
String text = ((Text) e.widget).getText();
705+
if (Policy.DEBUG_QUICK_ACCESS) {
706+
trace("Modify listener triggering proposals update"); //$NON-NLS-1$
707+
}
692708
updateProposals(text);
693709
});
694710
}
@@ -759,6 +775,9 @@ public void controlResized(ControlEvent e) {
759775
e.display.timerExec(100, () -> {
760776
if (table != null && !table.isDisposed() && filterText != null
761777
&& !filterText.isDisposed()) {
778+
if (Policy.DEBUG_QUICK_ACCESS) {
779+
trace("Resize listener triggering proposals update"); //$NON-NLS-1$
780+
}
762781
updateProposals(filterText.getText().toLowerCase());
763782
}
764783
resized = false;
@@ -932,4 +951,12 @@ public Text getFilterText() {
932951
public Table getTable() {
933952
return table;
934953
}
954+
955+
private static List<String> toIds(AtomicReference<List<QuickAccessEntry>[]> entries) {
956+
return Stream.of(entries.get()).flatMap(List::stream).map(e -> e.element.getId()).toList();
957+
}
958+
959+
private static void trace(String message) {
960+
Tracing.printTrace(QuickAccessContents.class.getName(), " | " + Thread.currentThread() + " | " + message); //$NON-NLS-1$ //$NON-NLS-2$
961+
}
935962
}

0 commit comments

Comments
 (0)