vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136)

Problem:  Filetype may be undetected when a SwapExists autocommand sets
          filetype in another buffer.
Solution: Make filetype detection state buffer-specific.  Also fix a
          similar problem for 'modified' (zeertzjq).

closes: vim/vim#14344

5bf6c2117f
This commit is contained in:
zeertzjq
2024-04-01 06:12:11 +08:00
committed by GitHub
parent e005b8d2eb
commit b08667d4f0
12 changed files with 109 additions and 32 deletions

View File

@@ -461,6 +461,19 @@ struct file_buffer {
bool b_marks_read; // Have we read ShaDa marks yet?
bool b_modified_was_set; ///< did ":set modified"
bool b_did_filetype; ///< FileType event found
bool b_keep_filetype; ///< value for did_filetype when starting
///< to execute autocommands
/// Set by the apply_autocmds_group function if the given event is equal to
/// EVENT_FILETYPE. Used by the readfile function in order to determine if
/// EVENT_BUFREADPOST triggered the EVENT_FILETYPE.
///
/// Relying on this value requires one to reset it prior calling
/// apply_autocmds_group().
bool b_au_did_filetype;
// The following only used in undo.c.
u_header_T *b_u_oldhead; // pointer to oldest header
u_header_T *b_u_newhead; // pointer to newest header; may not be valid