Skip to content

Commit a197607

Browse files
authored
FileType handler must not change the current window #175
If an autocmd changes the current window on FileType, it could raise unexpected errors. Giving a warning could help the user to fix them. fixes #158
1 parent 4f78ca1 commit a197607

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

autoload/dirvish.vim

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ function! s:open_dir(d, reload) abort
456456
call s:buf_render(b:dirvish._dir, get(b:dirvish, 'lastpath', ''))
457457
" Set up Dirvish before any other `FileType dirvish` handler.
458458
exe 'source '.fnameescape(s:srcdir.'/ftplugin/dirvish.vim')
459+
let curwin = winnr()
459460
setlocal filetype=dirvish
461+
if curwin != winnr() | throw 'FileType autocmd changed the window' | endif
460462
let b:dirvish._c = b:changedtick
461463
call s:apply_icons()
462464
endif

0 commit comments

Comments
 (0)