| 441 | } |
| 442 | |
| 443 | static void FoldCoffeeScriptDoc(unsigned int startPos, int length, int, |
| 444 | WordList *[], Accessor &styler) { |
| 445 | // A simplified version of FoldPyDoc |
| 446 | const int maxPos = startPos + length; |
| 447 | const int maxLines = styler.GetLine(maxPos - 1); // Requested last line |
| 448 | const int docLines = styler.GetLine(styler.Length() - 1); // Available last line |
| 449 | |
| 450 | // property fold.coffeescript.comment |
| 451 | const bool foldComment = styler.GetPropertyInt("fold.coffeescript.comment") != 0; |
| 452 | |
| 453 | const bool foldCompact = styler.GetPropertyInt("fold.compact") != 0; |
| 454 | |
| 455 | // Backtrack to previous non-blank line so we can determine indent level |
| 456 | // for any white space lines |
| 457 | // and so we can fix any preceding fold level (which is why we go back |
| 458 | // at least one line in all cases) |
| 459 | int spaceFlags = 0; |
| 460 | int lineCurrent = styler.GetLine(startPos); |
| 461 | int indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); |
| 462 | while (lineCurrent > 0) { |
| 463 | lineCurrent--; |
| 464 | indentCurrent = styler.IndentAmount(lineCurrent, &spaceFlags, NULL); |
| 465 | if (!(indentCurrent & SC_FOLDLEVELWHITEFLAG) |
| 466 | && !IsCommentLine(lineCurrent, styler)) |
| 467 | break; |
| 468 | } |
| 469 | int indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; |
| 470 | |
| 471 | // Set up initial loop state |
| 472 | int prevComment = 0; |
| 473 | if (lineCurrent >= 1) |
| 474 | prevComment = foldComment && IsCommentLine(lineCurrent - 1, styler); |
| 475 | |
| 476 | // Process all characters to end of requested range |
| 477 | // or comment that hangs over the end of the range. Cap processing in all cases |
| 478 | // to end of document (in case of comment at end). |
| 479 | while ((lineCurrent <= docLines) && ((lineCurrent <= maxLines) || prevComment)) { |
| 480 | |
| 481 | // Gather info |
| 482 | int lev = indentCurrent; |
| 483 | int lineNext = lineCurrent + 1; |
| 484 | int indentNext = indentCurrent; |
| 485 | if (lineNext <= docLines) { |
| 486 | // Information about next line is only available if not at end of document |
| 487 | indentNext = styler.IndentAmount(lineNext, &spaceFlags, NULL); |
| 488 | } |
| 489 | const int comment = foldComment && IsCommentLine(lineCurrent, styler); |
| 490 | const int comment_start = (comment && !prevComment && (lineNext <= docLines) && |
| 491 | IsCommentLine(lineNext, styler) && (lev > SC_FOLDLEVELBASE)); |
| 492 | const int comment_continue = (comment && prevComment); |
| 493 | if (!comment) |
| 494 | indentCurrentLevel = indentCurrent & SC_FOLDLEVELNUMBERMASK; |
| 495 | if (indentNext & SC_FOLDLEVELWHITEFLAG) |
| 496 | indentNext = SC_FOLDLEVELWHITEFLAG | indentCurrentLevel; |
| 497 | |
| 498 | if (comment_start) { |
| 499 | // Place fold point at start of a block of comments |
| 500 | lev |= SC_FOLDLEVELHEADERFLAG; |
nothing calls this directly
no test coverage detected