eRuby indenting capabilities

Tim Pope vim-ruby-devel at tpope.info
Mon Dec 4 16:36:46 EST 2006


On Tue, Dec 05, 2006 at 05:37:48AM +1100, Doug Kearns wrote:
> On Mon, Dec 04, 2006 at 11:05:41AM -0600, Tim Pope wrote:
> > On Tue, Dec 05, 2006 at 02:00:17AM +1100, Doug Kearns wrote:
> > > Tim,
> > > 
> > > I was just giving the new indent script a quick test drive prior to the
> > > next release and noticed that the following example doesn't work as I'd
> > > expect.
> > > 
> > > <%
> > > if true
> > > %>
> > > foobar
> > > <%
> > > end 
> > > %>
> > > 
> > > is indented as:
> > > 
> > > <%
> > >   if true
> > > %>
> > > foobar
> > > <%
> > >     end
> > >   %>
> > 
> > First, the end block should of course be
> > 
> > <%
> >   end
> > %>
> > 
> > This is what I get.  Do your results differ or was this a copy and
> > paste error?
> 
> No, I'm seeing 2 indent levels for the "end" and one for the "%>".  In
> fact, if I repeatedly indent this the final "%>" alternates between 1
> and 0 levels of indent.

Okay, after a little investigating, I found the cause, and I've had to
add a special case for an eRuby block with "end" as its first line.
After a couple of other minor tweaks here is the new indenting style
for the above example:

<%
  if true
  %>
  foobar
  <%
  end
%>

I'm not exactly sure what the correct behavior is for this example but
the above was easy to implement and seems reasonable.

I've kept the changes minimal to hopefulyl avoid a broken release.  If
anyone finds any problems let me know.

Tim


More information about the vim-ruby-devel mailing list