Issue: https://github.com/ClickHouse/ClickHouse/issues/83987 countCodePointsWithSeqLength calculates utf-8 code point position consistently with colors vector allocation (with iteration and `UTF8::seqLength`). This function replaces the use of `UTF8::countCodePoints()`, since, `UTF8::countCodePoints` and `UTF8::seqLength` seem to handle invalid utf-8 sequences inconsistently (e.g., hex literals li
| 144 | /// and crashes. TODO: @bharatnc fix `UTF8::countCodePoints` to handle invalid utf-8 sequences consistently |
| 145 | /// with `UTF8::seqLength` so that this helper function's usage can be removed. |
| 146 | static size_t countCodePointsWithSeqLength(const String & query, const char * end) |
| 147 | { |
| 148 | size_t code_points = 0; |
| 149 | const char * pos = query.data(); |
| 150 | while (pos < end) |
| 151 | { |
| 152 | pos += UTF8::seqLength(*pos); |
| 153 | ++code_points; |
| 154 | } |
| 155 | return code_points; |
| 156 | } |
| 157 | |
| 158 | void highlight(const String & query, std::vector<replxx::Replxx::Color> & colors, const Context & context, int cursor_position, bool rainbow_parentheses) |
| 159 | { |
no test coverage detected