aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-09-17 16:56:45 -0400
committerGitHub <noreply@github.com>2026-09-17 16:56:45 -0400
commit6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004 (patch)
tree321be87303392ebcaa9f9f985373c8aa53772fdc /src/nvim/eval.lua
parentd1fd8158de63107d2ada9f69c1a491d76edfc9aa (diff)
downloadrneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.tar.gz
rneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.tar.bz2
rneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.zip
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.
Diffstat (limited to 'src/nvim/eval.lua')
-rw-r--r--src/nvim/eval.lua7
1 files changed, 4 insertions, 3 deletions
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