* @brief Reformats only the given inclusive line range, preserving everything else. */
| 669 | * @brief Reformats only the given inclusive line range, preserving everything else. |
| 670 | */ |
| 671 | QString formatLineRange( |
| 672 | const QString& source, Language language, int firstLine, int lastLine, int indentSpaces) |
| 673 | { |
| 674 | if (source.isEmpty()) |
| 675 | return source; |
| 676 | |
| 677 | QStringList lines = splitLines(source); |
| 678 | if (firstLine < 0) |
| 679 | firstLine = 0; |
| 680 | |
| 681 | if (lastLine >= lines.size()) |
| 682 | lastLine = lines.size() - 1; |
| 683 | |
| 684 | if (firstLine > lastLine) |
| 685 | return source; |
| 686 | |
| 687 | const ScanResult scan = scanAllLines(lines, language); |
| 688 | |
| 689 | for (int i = firstLine; i <= lastLine; ++i) |
| 690 | lines[i] = |
| 691 | reformatOne(lines[i], scan.infos[i], scan.depthAtStart[i], scan.hangAtStart[i], indentSpaces); |
| 692 | |
| 693 | return lines.join(QLatin1Char('\n')); |
| 694 | } |
| 695 | |
| 696 | } // namespace DataModel::CodeFormatter |
no test coverage detected