Skip to content

Commit 8dbc101

Browse files
committed
Support :1A ./path to edit relative to the Rails root
1 parent a86ed1c commit 8dbc101

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

autoload/rails.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3153,6 +3153,9 @@ call s:add_methods('readable', ['open_command'])
31533153
function! s:find(cmd, file) abort
31543154
let djump = matchstr(a:file,'!.*\|#\zs.*\|:\zs\d*\ze\%(:in\)\=$')
31553155
let file = s:sub(a:file,'[#!].*|:\d*%(:in)=$','')
3156+
if file =~# '^\.\.\=\%([\/]\|$\)' && getcwd() !=# rails#app().path()
3157+
let file = rails#app().path() . s:sub(file[1:-1], '^\.\+', '')
3158+
endif
31563159
let cmd = (empty(a:cmd) ? '' : s:findcmdfor(a:cmd)) . ' '
31573160
if djump =~# '!'
31583161
if empty(a:cmd) || file !~# '\%(^\|:\)[\/]'
@@ -3215,7 +3218,7 @@ function! s:Related(cmd,line1,line2,count,...)
32153218
endfunction
32163219

32173220
function! s:Complete_related(A,L,P)
3218-
if a:L =~# '^[[:alpha:]]'
3221+
if a:L =~# '^[[:alpha:]]' || a:A =~# '^\w*:\|^\.\=[\/]'
32193222
return s:Complete_edit(a:A,a:L,a:P)
32203223
else
32213224
return s:Complete_find(a:A,a:L,a:P)

0 commit comments

Comments
 (0)