smartparens
smartparens copied to clipboard
[ruby-mode] Problems with barf inline delimiters
With the recent refactoring of barf functions, inline delimiters are not properly barfed:
begin
foo if bar|
end
Should return:
begin
foo
end if bar|
But fails because the code after the prehandler looks like this:
begin
foo
| if bar
end
Which make the inline "if" no longer inline... Ideas on how to solve this?
I guess returning:
begin
end
foo if bar|
Would also be fine.
Hm, this is ugly hack^TM but you could defvar
a variable for ruby mode to save the state in pre-handler and then use it in post-handler (and then erase it). I remember someone doing that in some pre/post handlers to emulate some delayed behaviour (which was later implemented in SP proper)
In the category of ugly hacks, I got something kind of working by inserting a char on the pre-handler and removing it in the post handler:
begin
foo
| if bar
end
begin
foo
|x if bar
end
begin
foo
endx| if bar
begin
foo
end| if bar
I'm gonna try some more, if I don't find an alternative I'll go for this solution.