-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Collapse fails in ruby mode if the file contains single-line class. #36
Comments
Thanks for the detail bug report! I think this will require a rewrite to the ruby core parser since the current logic doesn't support single line folding and the parser will just assume the end of line will be the start of the folding region. def foo; # Folding start here
"hello"
end in single line def foo; "hello" end # Folding overlaps (to the end of line) The logic needs to be updated so we can parser the ruby grammar better. Unlike C-like languages, it does not have simple way to find the proper folding region. P.S. Any similar languages will have the same issue. |
As I recall, this is the only pattern of Class, Module, and Method that can be defined in single line in Ruby. a) class Foo < Bar; end For a), b), c), d), It seems to be enough to determine that anything ending with "end" is a single-line-definition. def name=
...
end In summary, the following criteria seem to be good.
|
Thanks for the suggestions! I have manage to make this to work! Can you upgrade to the latest version and see if it works? Thanks! 👍 |
There were a few things that bothered me. Errors have occurred
Run origami-close-all-nodes
Run origami-close-all-nodes The class name will be hiddenI dodn't think it was necessary to hide the class name. After all, I'll have to open everything because I won't be able to see the outlines. |
Does the code valid in Ruby? Sorry I am not very familiar to Ruby code. The problem is
Can you set Hiding the class name isn't intentional. As I said, the parser doesn't know where to Before(fold end) (fold start) class ClassName ... end # folding error, overlaps Afterclass (fold start) ClassName ... (fold end) end # Current workaround I propose shift another word towards to the right? So it should end up like class ClassName(fold start) ... (fold end) end # Current workaround |
def bar(v)
print v if v
end Run origami-close-all-nodes
|
Description![:octocat: :octocat:](https://github.githubassets.com/images/icons/emoji/octocat.png)
I get an error when I fold the code in a ruby file that contains a single-line class, module, and method.
As a side note, in Ruby, classes, modules, and methods can each be defined in a single line, as shown below:
Reproduction guide 🪲
Observed behaviour: 👀 💔
(error "Offset is not within the range of the node: beg=1 ...")
Expected behaviour: ❤️ 😄
No error in ruby file contains a single-line-definition
System Info 💻
Backtrace 🐾
The text was updated successfully, but these errors were encountered: