Skip to content

Commit

Permalink
[Ruby] Add missing percent literal delimiters < and >.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Mar 15, 2024
1 parent 15bcf97 commit 6984ae8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
9 changes: 6 additions & 3 deletions scintilla/lexers/LexBash.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ constexpr bool IsBashNumber(int digit, int base) noexcept {
}

constexpr int opposite(int ch) noexcept {
if (ch == '(') return ')';
if (ch == '[') return ']';
if (ch == '{') return '}';
if (ch == '(') {
return ')';
}
if (AnyOf<'[', '{'>(ch)) {
return ch + 2;
}
return ch;
}

Expand Down
13 changes: 9 additions & 4 deletions scintilla/lexers/LexPerl.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,15 @@ int actualNumStyle(int numberStyle) noexcept {
}

constexpr int opposite(int ch) noexcept {
if (ch == '(') return ')';
if (ch == '[') return ']';
if (ch == '{') return '}';
if (ch == '<') return '>';
if (ch == '(') {
return ')';
}
if (AnyOf<'[', '{'>(ch)) {
return ch + 2;
}
if (ch == '<') {
return '>';
}
return ch;
}

Expand Down
15 changes: 9 additions & 6 deletions scintilla/lexers/LexRuby.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,17 @@ bool lookingAtHereDocDelim(LexAccessor &styler, Sci_Position pos, const char *He
return false;
}

//XXX Identical to Perl, put in common area
// https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-Percent+Literals
constexpr char opposite(char ch) noexcept {
if (ch == '(')
if (ch == '(') {
return ')';
if (ch == '[')
return ']';
if (ch == '{')
return '}';
}
if (AnyOf<'[', '{'>(ch)) {
return ch + 2;
}
if (ch == '<') {
return '>';
}
return ch;
}

Expand Down

0 comments on commit 6984ae8

Please sign in to comment.