boolean (Editor editor, final DataContext dataContext) { if (inCheck) { return true; } inCheck = true; try { if (editor == null) { return false; } Editor hostEditor = dataContext == null ? null : CommonDataKeys.HOST_EDITOR.getData(dataContext); if (hostEditor == null) { hostEditor = editor; } final boolean[] result = new boolean[1]; final CaretTask check = (___, __) -> result[0] = true; if (myRunForEachCaret) { hostEditor.getCaretModel().runForEachCaret(caret -> doIfEnabled(caret, dataContext, check)); } else { doIfEnabled(hostEditor.getCaretModel().getCurrentCaret(), dataContext, check); } return result[0]; } finally { inCheck = false; } }