Bugs: Browse | Submit New | Admin

[#12421] Incorrect indent if symbol is "if, for, while, until, case, unless, begin"

Date:
2007-07-19 16:07
Priority:
3
Submitted By:
Simon Arnaud (maz)
Assigned To:
Gavin Sinclair (gsinclair)
Category:
Indent
State:
Closed
Summary:
Incorrect indent if symbol is "if, for, while, until, case, unless, begin"

Detailed description
I'm running into the problem with markaby, when inserting a label for an input.

sample code :

ul do
  li do
    label "Hostname :", :for => 'hostname'
    input :id => 'hostname', :type => :text, :name => 'hostname'
  end
end

after an auto-indent (gg=G)

ul do
  li do
    label "Hostname :", :for => 'hostname'
                           input :id => 'hostname', :type => :text, :name => 'hostname'
  end
end

The problem lies in 's:ruby_indent_keywords'

" Regex used for words that, at the start of a line, add a level of indent.
let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' .
      \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' .
      \ '\|rescue\)\>' .
      \ '\|\%([*+/,=:-]\|<<\|>>\)\s*\zs' .
      \    '\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'

The last line says to indent if the preceeding line has one the words listed.
However a word is still the default for vim, and not for ruby.

Adding the following near the beginning solves the problem :

set iskeyword+=:

It will solve the problems for symbols, but I'm not sure on the side effects on  'if ...:' statements.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-07-22 03:17
Sender: Tim Pope

A fix for this issue was committed July 16.  Please reopen if
this is an issue with the latest CVS.

As a side note, setting iskeyword has numerous side effects and
is not an appropriate solution.
Date: 2007-07-19 16:32
Sender: Simon Arnaud

After looking at vim regexp, a better, and less intrusive,
solution might be :

-       \   
'\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'

+       \   
'\@!:\<\%(if\|for\|while\|until\|case\|unless\|begin\)\>'

both line 57 and 69

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

Field Old Value Date By
status_idOpen2007-07-22 03:17tpope
close_date2007-07-22 03:172007-07-22 03:17tpope
summaryIncorrect indent if symbol is "if, for, while, until, case, unless, begin"2007-07-19 16:32maz