| 70 | //----------------------------------------------------------------------------- |
| 71 | |
| 72 | void OutputFormatHelper::RemoveIndent() |
| 73 | { |
| 74 | /* After a newline we are already indented by one level to much. Try to decrease it. */ |
| 75 | if(0 != mDefaultIndent) { |
| 76 | // go the string backwards and find the first non-whitespace character |
| 77 | const auto res = std::find_if( |
| 78 | std::rbegin(mOutput), std::rbegin(mOutput) + SCOPE_INDENT, [](const char& c) { return ' ' != c; }); |
| 79 | |
| 80 | // check if the string did end with at least one whitespace |
| 81 | if(const auto& end = std::rbegin(mOutput); res != end) { |
| 82 | // remove the whitespaces at the end of the string |
| 83 | mOutput.resize(mOutput.size() - std::distance(end, res)); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | //----------------------------------------------------------------------------- |
| 88 | |
| 89 | } // namespace clang::insights |