Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] Fix code folding for SCE_RB_STRING_QW #132

Closed
zufuliu opened this issue Feb 9, 2023 · 2 comments
Closed

[Ruby] Fix code folding for SCE_RB_STRING_QW #132

zufuliu opened this issue Feb 9, 2023 · 2 comments
Labels
committed Issue fixed in repository but not in release ruby Caused by the ruby lexer

Comments

@zufuliu
Copy link
Contributor

zufuliu commented Feb 9, 2023

Current code fails for following ruby code (from https://docs.ruby-lang.org/en/master/syntax/literals_rdoc.html#label-25w+and+-25W-3A+String-Array+Literals)

%W(#{1 + 1})

Which seems can be fixed with this change (remove else)

diff --git a/lexers/LexRuby.cxx b/lexers/LexRuby.cxx
index af585756..96e32a5f 100644
--- a/lexers/LexRuby.cxx
+++ b/lexers/LexRuby.cxx
@@ -1895,7 +1895,8 @@ static void FoldRbDoc(Sci_PositionU startPos, Sci_Position length, int initStyle
         } else if (style == SCE_RB_STRING_QW) {
             if (stylePrev != style) {
                 levelCurrent++;
-            } else if (styleNext != style) {
+            }
+            if (styleNext != style) {
                 levelCurrent--;
             }
         }
@nyamatongwe nyamatongwe added the ruby Caused by the ruby lexer label Feb 9, 2023
@nyamatongwe
Copy link
Member

To clarify, it is the end character ) that is causing the problem since it transitions both to and from SCE_RB_STRING_QW.

The intention of the SCE_RB_STRING_QW case is to fold multiline array literals like this example.

keywords = %w[
__FILE__ and def end in or self unless __LINE__ begin
defined? ensure module redo super until BEGIN break do false next rescue
then when END case else for nil retry true while alias class elsif if
not return undef yield
]
puts(keywords.join('|'))

@nyamatongwe nyamatongwe added the committed Issue fixed in repository but not in release label Feb 10, 2023
@nyamatongwe
Copy link
Member

Included in 5.2.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
committed Issue fixed in repository but not in release ruby Caused by the ruby lexer
Projects
None yet
Development

No branches or pull requests

2 participants