private static int getPreviousLineStopOffset(@NotNull Document document, @NotNull CaretStop lineStop,
                                               int lineNumber, boolean isAtLineStart) {
    if (lineNumber - 1 < 0) {
      return 0;
    }
    else if (!isAtLineStart) {
      return lineStop.isAtStart() ? document.getLineStartOffset(lineNumber) :
             lineStop.isAtEnd() ? document.getLineEndOffset(lineNumber - 1) :
             0;
    }
    else {
      return lineStop.isAtEnd() ? document.getLineEndOffset(lineNumber - 1) :
             lineStop.isAtStart() ? document.getLineStartOffset(lineNumber - 1) :
             0;
    }
  }
private static int getPreviousLineStopOffset(@NotNull Document document, @NotNull CaretStop lineStop,
                                               int lineNumber, boolean isAtLineStart)