SearchArea (@NotNull Editor editor, @NotNull FindModel findModel) { if (findModel.isGlobal()) { return globalSearchArea; } SearchArea searchArea; if (ApplicationManager.getApplication().isDispatchThread()) { searchArea = getLocalSearchArea(editor, findModel); } else { CompletableFuture<SearchArea> future = new CompletableFuture<>(); try { SwingUtilities.invokeAndWait(() -> { var result = getLocalSearchArea(editor, findModel); future.complete(result); }); } catch (InterruptedException | InvocationTargetException ignore) { } searchArea = future.getNow(null); } if (searchArea != null && searchArea.startOffsets.length > 0) { return searchArea; } else { return globalSearchArea; } }