void (Editor e) { Project project = mySearchResults.getProject(); if (!ReadonlyStatusHandler.ensureDocumentWritable(project, e.getDocument())) { return; } if (mySearchResults.getFindModel() != null) { final FindModel copy = new FindModel(); copy.copyFrom(mySearchResults.getFindModel()); final SelectionModel selectionModel = mySearchResults.getEditor().getSelectionModel(); final int offset; if (!selectionModel.hasSelection() || copy.isGlobal()) { copy.setGlobal(true); offset = 0; } else { offset = selectionModel.getBlockSelectionStarts()[0]; } LocalHistoryAction action = LocalHistory.getInstance().startAction( FindBundle.message("find.replace.all.local.history.action", copy.getStringToFind(), copy.getStringToReplace())); try { FindUtil.replace(project, e, offset, copy, this); } finally { action.finish(); } } }