fix(editor): reference result is not shown for single reference in the same file

This is caused due to setSeletion(Range) being called on a background thread (fixes #1248).
This commit is contained in:
Akash Yadav
2023-09-28 23:49:07 +05:30
parent 1eb99c5854
commit 191883c887
@@ -600,7 +600,6 @@ public class IDEEditor extends CodeEditor implements IEditor, ILspEditor {
final CompletableFuture<ReferenceResult> future,
final ReferenceResult result, final Throwable error
) {
LOG.debug("onFindRefsResult");
dismissOnUiThread(flashbar);
if (result == null || languageClient == null || future.isCancelled() ||
@@ -615,15 +614,17 @@ public class IDEEditor extends CodeEditor implements IEditor, ILspEditor {
return;
}
if (result.getLocations().size() == 1) {
final var loc = result.getLocations().get(0);
if (DocumentUtils.isSameFile(loc.getFile(), getFile().toPath())) {
setSelection(loc.getRange());
return;
ThreadUtils.runOnUiThread(() -> {
if (result.getLocations().size() == 1) {
final var loc = result.getLocations().get(0);
if (DocumentUtils.isSameFile(loc.getFile(), getFile().toPath())) {
setSelection(loc.getRange());
return;
}
}
}
ThreadUtils.runOnUiThread(() -> languageClient.showLocations(result.getLocations()));
languageClient.showLocations(result.getLocations());
});
}
/**