Skip to content

Commit a03dbc9

Browse files
committed
Apply Quick Access results by request state instead of last job
QuickAccessContents.updateProposals applied a compute job's results only when it was still the last scheduled job (computeProposalsJob == currentComputeEntriesJob). A shell resize schedules another updateProposals right after a compute finishes, so the still-valid results of the finished job were discarded, and the newer job was then cancelled by the following resize before it rendered anything. The table stayed empty, which is the intermittent failure in QuickAccessDialogTest.testPreviousChoicesAvailableForExtension. In addition, the modify listener passed the raw filter text while the resize and show-all listeners passed a lower-cased one, so a single UI state produced two competing jobs and only the lower-cased one matched (the matcher requires a lower-cased filter). Normalize the filter to lower case once in updateProposals so all callers share one filter string, and apply a finished job's results when they still match the current request state (filter text and show-all) instead of when the job happens to be the last scheduled one. A valid result is no longer dropped because a later recompute was scheduled, while a result for a filter the user has since changed is still rejected. Addresses #4009
1 parent fe783d5 commit a03dbc9

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,12 @@ private int computeNumberOfItems() {
147147
/**
148148
* Refreshes the contents of the quick access shell
149149
*
150-
* @param filter The filter text to apply to results
150+
* @param filterInput The filter text to apply to results
151151
*/
152-
public void updateProposals(String filter) {
152+
public void updateProposals(String filterInput) {
153+
// Lower-case once so all callers share one filter string; the matcher and
154+
// previous-pick lookup also require a lower-cased filter.
155+
final String filter = filterInput == null ? "" : filterInput.toLowerCase(); //$NON-NLS-1$
153156
if (Policy.DEBUG_QUICK_ACCESS) {
154157
trace("Updating proposals with filter: \"" + filter + "\""); //$NON-NLS-1$ //$NON-NLS-2$
155158
}
@@ -168,6 +171,8 @@ public void updateProposals(String filter) {
168171
String computingMessage = NLS.bind(QuickAccessMessages.QuickaAcessContents_computeMatchingEntries, filter);
169172
int maxNumberOfItemsInTable = computeNumberOfItems();
170173
lastComputedItemCount = maxNumberOfItemsInTable;
174+
// Captured to detect a show-all toggle while this compute runs.
175+
final boolean requestShowAllMatches = showAllMatches;
171176
AtomicReference<List<QuickAccessEntry>[]> entries = new AtomicReference<>();
172177
final Job currentComputeEntriesJob = Job.create(computingMessage, theMonitor -> {
173178
entries.set(
@@ -203,12 +208,20 @@ public void done(IJobChangeEvent event) {
203208
", entries: " + toIds(entries)); //$NON-NLS-1$
204209
}
205210
computingFeedbackJob.cancel();
206-
if (computeProposalsJob == currentComputeEntriesJob && event.getResult().isOK()
207-
&& !table.isDisposed()) {
208-
if (Policy.DEBUG_QUICK_ACCESS) {
209-
trace("Setting quick access contents: " + toIds(entries)); //$NON-NLS-1$
210-
}
211+
if (event.getResult().isOK() && !table.isDisposed()) {
211212
display.asyncExec(() -> {
213+
if (table.isDisposed() || filterText == null || filterText.isDisposed()) {
214+
return;
215+
}
216+
// Apply if the results still match the current filter and show-all,
217+
// not only when this is the last scheduled job.
218+
if (!filter.equals(filterText.getText().toLowerCase())
219+
|| requestShowAllMatches != showAllMatches) {
220+
return;
221+
}
222+
if (Policy.DEBUG_QUICK_ACCESS) {
223+
trace("Setting quick access contents: " + toIds(entries)); //$NON-NLS-1$
224+
}
212225
computingFeedbackJob.cancel();
213226
refreshTable(perfectMatch, entries.get(), filter);
214227
});

0 commit comments

Comments
 (0)