/**
  * We know that there are problems with incremental soft wraps cache update at the moment. Hence,
  * we may implement full cache reconstruction when the problem is encountered in order to avoid
  * customer annoyance.
  *
  * <p>However, the problems still should be fixed, hence, we report them only if dedicated flag is
  * set.
  *
  * <p>Current method encapsulates the logic mentioned above.
  *
  * @param task command object that which execution may trigger incremental update of update soft
  *     wraps cache
  */
 @SuppressWarnings({"UseOfArchaicSystemPropertyAccessors"})
 private void executeSafely(SoftWrapAwareTask task) {
   try {
     task.run(true);
   } catch (Throwable e) {
     if (Boolean.getBoolean(DEBUG_PROPERTY_NAME)
         || ApplicationManager.getApplication().isUnitTestMode()) {
       String info = myEditor.dumpState();
       LOG.error(
           String.format("Unexpected exception occurred during performing '%s'", task), e, info);
     }
     myEditor.getFoldingModel().rebuild();
     myDataMapper.release();
     myApplianceManager.reset();
     myStorage.removeAll();
     myApplianceManager.recalculateIfNecessary();
     try {
       task.run(true);
     } catch (Throwable e1) {
       String info = myEditor.dumpState();
       LOG.error(
           String.format("Can't perform %s even with complete soft wraps cache re-parsing", task),
           e1,
           info);
       myEditor.getSettings().setUseSoftWraps(false);
       task.run(false);
     }
   }
 }
  @Override
  public boolean isVisible(SoftWrap softWrap) {
    FoldingModel foldingModel = myEditor.getFoldingModel();
    int start = softWrap.getStart();
    if (foldingModel.isOffsetCollapsed(start)) {
      return false;
    }

    // There is a possible case that soft wrap and collapsed folding region share the same offset,
    // i.e. soft wrap is represented
    // before the folding. We need to return 'true' in such situation. Hence, we check if offset
    // just before the soft wrap
    // is collapsed as well.
    return start <= 0 || !foldingModel.isOffsetCollapsed(start - 1);
  }