@@ -292,6 +292,25 @@ class QuoteCls {
292292 }
293293};
294294
295+ constexpr bool isPercentLiteral (int state) noexcept {
296+ return state == SCE_RB_STRING_Q
297+ || state == SCE_RB_STRING_QQ
298+ // excluded SCE_RB_STRING_QR
299+ || state == SCE_RB_STRING_W
300+ || state == SCE_RB_STRING_QW
301+ || state == SCE_RB_STRING_I
302+ || state == SCE_RB_STRING_QI
303+ || state == SCE_RB_STRING_QS
304+ || state == SCE_RB_STRING_QX;
305+ }
306+
307+ constexpr bool isInterpolableLiteral (int state) noexcept {
308+ return state != SCE_RB_STRING_Q
309+ && state != SCE_RB_STRING_W
310+ && state != SCE_RB_STRING_I
311+ && state != SCE_RB_STRING_QS
312+ && state != SCE_RB_CHARACTER;
313+ }
295314
296315void enterInnerExpression (int *p_inner_string_types,
297316 int *p_inner_expn_brace_counts,
@@ -756,11 +775,14 @@ void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
756775 SCE_RB_STRING_Q,
757776 SCE_RB_STRING_QQ,
758777 SCE_RB_STRING_QR,
778+ SCE_RB_STRING_W,
759779 SCE_RB_STRING_QW,
760- SCE_RB_STRING_QW,
761- SCE_RB_STRING_QX
780+ SCE_RB_STRING_QX,
781+ SCE_RB_STRING_I,
782+ SCE_RB_STRING_QI,
783+ SCE_RB_STRING_QS,
762784 };
763- constexpr const char *q_chars = " qQrwWx " ;
785+ constexpr const char *q_chars = " qQrwWxiIs " ;
764786
765787 // In most cases a value of 2 should be ample for the code in the
766788 // Ruby library, and the code the user is likely to enter.
@@ -1479,8 +1501,7 @@ void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
14791501 }
14801502 }
14811503 // Quotes of all kinds...
1482- } else if (state == SCE_RB_STRING_Q || state == SCE_RB_STRING_QQ ||
1483- state == SCE_RB_STRING_QX || state == SCE_RB_STRING_QW ||
1504+ } else if (isPercentLiteral (state) ||
14841505 state == SCE_RB_STRING || state == SCE_RB_CHARACTER ||
14851506 state == SCE_RB_BACKTICKS) {
14861507 if (!Quote.Down && !isspacechar (ch)) {
@@ -1499,8 +1520,7 @@ void ColouriseRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
14991520 Quote.Count ++;
15001521 } else if (ch == ' #' && chNext == ' {'
15011522 && inner_string_count < INNER_STRINGS_MAX_COUNT
1502- && state != SCE_RB_CHARACTER
1503- && state != SCE_RB_STRING_Q) {
1523+ && isInterpolableLiteral (state)) {
15041524 // process #{ ... }
15051525 styler.ColourTo (i - 1 , state);
15061526 styler.ColourTo (i + 1 , SCE_RB_OPERATOR);
0 commit comments