mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 17:41:59 +00:00
Highlight only when necessary
This commit is contained in:
parent
da05238c8e
commit
9664fb9249
@ -128,6 +128,7 @@ void highlight(const String & query, std::vector<replxx::Replxx::Color> & colors
|
||||
Tokens tokens(begin, end, 1000, true);
|
||||
IParser::Pos token_iterator(tokens, static_cast<uint32_t>(1000), static_cast<uint32_t>(10000));
|
||||
Expected expected;
|
||||
expected.enable_highlighting = true;
|
||||
|
||||
/// We don't do highlighting for foreign dialects, such as PRQL and Kusto.
|
||||
/// Only normal ClickHouse SQL queries are highlighted.
|
||||
|
@ -44,6 +44,9 @@ static bool intersects(T a_begin, T a_end, T b_begin, T b_end)
|
||||
|
||||
void Expected::highlight(HighlightedRange range)
|
||||
{
|
||||
if (!enable_highlighting)
|
||||
return;
|
||||
|
||||
auto it = highlights.lower_bound(range);
|
||||
while (it != highlights.end() && range.begin < it->end)
|
||||
{
|
||||
|
@ -56,6 +56,7 @@ struct Expected
|
||||
absl::InlinedVector<const char *, 7> variants;
|
||||
const char * max_parsed_pos = nullptr;
|
||||
|
||||
bool enable_highlighting = false;
|
||||
std::set<HighlightedRange> highlights;
|
||||
|
||||
/// 'description' should be statically allocated string.
|
||||
|
Loading…
Reference in New Issue
Block a user