Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Make matchit's "%" ignore Range.end method #125

Merged
merged 1 commit into from

2 participants

@mmorearty

With the following code, matchit's "%" key will now jump between line 1
and line 3, as it should:

if x
  (1..5).end
end

Ruby allows methods with keyword names, such as "end". That was confusing Vim's "%" command (go to match), since the end in (1..5).end looks like a keyword.

The fix is similar to what is done farther down in syntax/ruby.vim, in the section that defines rubyKeywordAsMethod: If "end" is preceded by "." or "::", then it is a method name.

@mmorearty mmorearty Make matchit's "%" ignore Range.end method
With the following code, matchit's "%" key will now jump between line 1
and line 3, as it should:

  if x
    (1..5).end
  end
c7cb532
@tpope tpope merged commit 5f65739 into vim-ruby:master
@tpope
Owner

Seems legit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 23, 2013
  1. @mmorearty

    Make matchit's "%" ignore Range.end method

    mmorearty authored
    With the following code, matchit's "%" key will now jump between line 1
    and line 3, as it should:
    
      if x
        (1..5).end
      end
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  syntax/ruby.vim
View
2  syntax/ruby.vim
@@ -228,7 +228,7 @@ if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive")
" statements without 'do'
syn region rubyBlockExpression matchgroup=rubyControl start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
syn region rubyCaseExpression matchgroup=rubyConditional start="\<case\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
- syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold
+ syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold
syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!" contained containedin=rubyCaseExpression
syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression
Something went wrong with that request. Please try again.