From 6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 17 Sep 2026 16:56:45 -0400 Subject: fix(filetype): empty 'filetype' skips :setfiletype #41958 Problem: After `:restart` a restored buffer can have an empty 'filetype'. Lazy LSP setup during the read replays FileType via `:doautoall`, which sets `did_filetype` even though `filetype=''`. :e foo.md :restart :set ft? " filetype= Solution: Set `did_filetype` only if 'filetype' is non-empty. --- src/nvim/eval.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval.lua') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 2e37a8bc76..3e4e535970 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -1952,10 +1952,11 @@ M.funcs = { did_filetype = { desc = [=[ Returns |TRUE| when autocommands are being executed and the - FileType event has been triggered at least once. Can be used - to avoid triggering the FileType event again in the scripts - that detect the file type. |FileType| + FileType event triggered at least once for a buffer with + a non-empty 'filetype'. Can be used to avoid triggering + the FileType event again in the |ftdetect| scripts. |FileType| Returns |FALSE| when `:setf FALLBACK` was used. + When editing another file, the counter is reset, thus this really checks if the FileType event has been triggered for the current buffer. This allows an autocommand that starts -- cgit