Skip to content

Commit cdd34c5

Browse files
committed
Fix reloading of log file
Closes tpope#537
1 parent 2c353f8 commit cdd34c5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

ftplugin/railslog.vim

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ let b:did_ftplugin = 1
55

66
function! s:reload_log() abort
77
if &buftype == 'quickfix' && get(w:, 'quickfix_title') =~ '^:cgetfile'
8-
let pos = getpos('.')
9-
exe 'cgetfile' exists('*fnameescape') ? fnameescape(w:quickfix_title[10:-1]) : w:quickfix_title[10:-1]
10-
call setpos('.', pos)
8+
let cmd = 'cgetfile ' .
9+
\ (exists('*fnameescape') ? fnameescape(w:quickfix_title[10:-1]) : w:quickfix_title[10:-1]) .
10+
\ "|call setpos('.', " . string(getpos('.')) . ")"
1111
else
12-
checktime
13-
endif
14-
if &l:filetype !=# 'railslog'
15-
setfiletype railslog
12+
let cmd = 'checktime'
1613
endif
14+
return cmd . "|if &l:filetype !=# 'railslog'|setfiletype railslog|endif"
1715
endfunction
1816

1917
if exists('w:quickfix_title')
2018
runtime! ftplugin/qf.vim ftplugin/qf_*.vim ftplugin/qf/*.vim
2119
endif
2220
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe')
23-
nnoremap <buffer> <silent> R :<C-U>call <SID>reload_log()<CR>
24-
nnoremap <buffer> <silent> G :<C-U>call <SID>reload_log()<Bar>exe v:count ? v:count : '$'<CR>
21+
nnoremap <buffer> <silent> R :<C-U>exe <SID>reload_log()<CR>
22+
nnoremap <buffer> <silent> G :<C-U>exe <SID>reload_log()<Bar>exe v:count ? v:count : '$'<CR>
2523
nnoremap <buffer> <silent> q :bwipe<CR>
2624
let b:undo_ftplugin .= '|sil! nunmap <buffer> R|sil! nunmap <buffer> G|sil! nunmap <buffer> q'
2725
setlocal noswapfile autoread

0 commit comments

Comments
 (0)