[prql] fix double quoted string highlighting

pull/1265/head
Tim Stack 2 months ago
parent 572c758dcc
commit e71ec01ac3

@ -4634,20 +4634,11 @@ from *table*
.. code-block:: custsqlite .. code-block:: custsqlite
;from db.http_status_codes | take 3 ;from http_status_codes | take 3
✘ error: failed to compile SQL statement status message
reason: no such table: db.http_status_codes 100 Continue
--> command:1 101 Switchi⋯otocols
| SELECT 102 Processing
| *
| FROM
| db.http_status_codes
| LIMIT
| 3
|
| -- Generated by PRQL compiler version:0.11.5 target:sql.sqlite (https://prql-lang.org)
|
To use an array literal as a source: To use an array literal as a source:

@ -280,9 +280,7 @@ readline_sqlite_highlighter_int(attr_line_t& al, int x, line_range sub)
|| attr.sa_type == &lnav::sql::PRQL_NUMBER_ATTR) || attr.sa_type == &lnav::sql::PRQL_NUMBER_ATTR)
{ {
alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_NUMBER)); alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_NUMBER));
} else if (attr.sa_type == &SQL_STRING_ATTR } else if (attr.sa_type == &SQL_STRING_ATTR) {
|| attr.sa_type == &lnav::sql::PRQL_STRING_ATTR)
{
if (lr.length() > 1 && al.al_string[lr.lr_end - 1] == '\'') { if (lr.length() > 1 && al.al_string[lr.lr_end - 1] == '\'') {
alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_STRING)); alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_STRING));
} else { } else {
@ -291,6 +289,8 @@ readline_sqlite_highlighter_int(attr_line_t& al, int x, line_range sub)
alb.overlay_attr_for_char(lr.lr_start, alb.overlay_attr_for_char(lr.lr_start,
VC_ROLE.value(role_t::VCR_ERROR)); VC_ROLE.value(role_t::VCR_ERROR));
} }
} else if (attr.sa_type == &lnav::sql::PRQL_STRING_ATTR) {
alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_STRING));
} else if (attr.sa_type == &SQL_OPERATOR_ATTR } else if (attr.sa_type == &SQL_OPERATOR_ATTR
|| attr.sa_type == &lnav::sql::PRQL_OPERATOR_ATTR) || attr.sa_type == &lnav::sql::PRQL_OPERATOR_ATTR)
{ {

@ -485,7 +485,7 @@ static readline_context::command_t sql_commands[] = {
.with_parameter({"table", "The table to use as a source"}) .with_parameter({"table", "The table to use as a source"})
.with_example({ .with_example({
"To pull data from the 'http_status_codes' database table", "To pull data from the 'http_status_codes' database table",
"from db.http_status_codes | take 3", "from http_status_codes | take 3",
help_example::language::prql, help_example::language::prql,
}) })
.with_example({ .with_example({

@ -1397,7 +1397,7 @@ annotate_prql_statement(attr_line_t& al)
&PRQL_STRING_ATTR, &PRQL_STRING_ATTR,
}, },
{ {
lnav::pcre2pp::code::from_const(R"(\A(?:f|r|s)?\"([^\"]|\\.)*\")"), lnav::pcre2pp::code::from_const(R"(\A(?:f|r|s)?"([^\"]|\\.)*")"),
&PRQL_STRING_ATTR, &PRQL_STRING_ATTR,
}, },
{ {

Loading…
Cancel
Save