Skip to content

Commit 7496444

Browse files
committed
Look for foos/_foo on render @foos
Resolves: tpope#586
1 parent 9c92daf commit 7496444

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

autoload/rails.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,9 +2295,13 @@ function! s:match_partial(func) abort
22952295
elseif res =~# '^\w\+\%(\.\w\+\)\=$'
22962296
let res = rails#singularize(s:sub(res, '^\w*\.', ''))
22972297
return s:findview(rails#pluralize(res).'/_'.res)
2298-
else
2299-
return s:findview(s:sub(s:sub(res, '^:=[''"@]=', ''), '[^/]*$', '_&'))
2298+
elseif res =~# '^@\w\+$'
2299+
let view = s:findview('_' . rails#singularize(res[1:-1]), '')
2300+
if !empty(view)
2301+
return view
2302+
endif
23002303
endif
2304+
return s:findview(s:sub(s:sub(res, '^:=[''"@]=', ''), '[^/]*$', '_&'))
23012305
endfunction
23022306

23032307
function! s:suffixes(type) abort
@@ -3200,9 +3204,9 @@ endfunction
32003204

32013205
call s:add_methods('readable', ['resolve_view', 'resolve_layout'])
32023206

3203-
function! s:findview(name) abort
3207+
function! s:findview(name, ...) abort
32043208
let view = s:active() ? rails#buffer().resolve_view(a:name, line('.')) : ''
3205-
return empty(view) ? (a:name =~# '\.' ? a:name : a:name . '.' . s:format()) : view
3209+
return len(view) ? view : a:0 ? a:1 : (a:name =~# '\.' ? a:name : a:name . '.' . s:format())
32063210
endfunction
32073211

32083212
function! s:findlayout(name)

0 commit comments

Comments
 (0)