smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

[ruby-mode] Problems with barf inline delimiters

Open Jell opened this issue 11 years ago • 3 comments

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?

Jell avatar Oct 12 '13 16:10 Jell

I guess returning:

begin
end
foo if bar|

Would also be fine.

Jell avatar Oct 12 '13 16:10 Jell

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)

Fuco1 avatar Oct 12 '13 17:10 Fuco1

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.

Jell avatar Oct 12 '13 17:10 Jell