Skip to content

Commit 91f2287

Browse files
committed
Fix gf on render :layout in views
Closes tpope#149.
1 parent 9913aff commit 91f2287

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

autoload/rails.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,13 @@ function! s:RailsFind()
19171917
let res = s:findamethod('\%(match\|get\|put\|post\|delete\|redirect\)\s*(\=\s*[:''"][^''"]*[''"]\=\s*\%(\%(,\s*:to\s*\)\==>\|,\s*to:\)\s*','app/controllers/\1')
19181918
if res =~ '#'|return s:sub(res,'#','_controller.rb#')|endif
19191919

1920+
if !buffer.type_name('controller', 'mailer')
1921+
let res = s:sub(s:sub(s:findasymbol('layout','\1'),'^/',''),'[^/]+$','_&')
1922+
if res != ""|return res."\n".s:findview(res)|endif
1923+
let res = s:sub(s:sub(s:findfromview('render\s*(\=\s*\%(:layout\s\+=>\|layout:\)\s*','\1'),'^/',''),'[^/]+$','_&')
1924+
if res != ""|return res."\n".s:findview(res)|endif
1925+
endif
1926+
19201927
let res = s:findamethod('layout','\=s:findlayout(submatch(1))')
19211928
if res != ""|return res|endif
19221929

@@ -2046,7 +2053,7 @@ function! s:RailsIncludefind(str,...)
20462053
if a:str =~# '\u'
20472054
" Classes should always be in .rb files
20482055
let str .= '.rb'
2049-
elseif line =~# ':partial\s*=>\s*'
2056+
elseif line =~# ':partial\s*=>\s*' || (line =~# ':layout\s*=>\s*' && !rails#buffer().type_name('controller', 'mailer'))
20502057
let str = s:sub(str,'[^/]+$','_&')
20512058
let str = s:findview(str)
20522059
elseif line =~# '\<layout\s*(\=\s*' || line =~# ':layout\s*=>\s*'

0 commit comments

Comments
 (0)