Skip BufRead for an unnamed empty buffer (#1341)

Loading a plugin on demand triggers BufRead to apply ftdetect and ftplugin files, but there is nothing to detect in an unnamed empty buffer such as the one Vim creates on startup.

Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com>
This commit is contained in:
mattn authored and GitHub committed 2026-10-15 13:36:11 +09:00
1 parent 4da42e9a5c
commit 7e5aae5e11
1 file changed
+4
+4
View File
@@ -570,6 +570,10 @@ function! s:doautocmd(...)
endfunction
function! s:dobufread(names)
" Nothing to detect in an unnamed empty buffer, e.g. the one on startup
if empty(bufname('%')) && line('$') == 1 && empty(getline(1))
return
endif
for name in a:names
let path = s:rtp(g:plugs[name])
for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin']