comparison src/autocmd.c @ 34705:159d598e6781 v9.1.0231

patch 9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf Commit: https://github.com/vim/vim/commit/5bf6c2117fcef85fcf046c098dd3eb72a0147859 Author: zeertzjq <zeertzjq@outlook.com> Date: Sun Mar 31 18:41:27 2024 +0200 patch 9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf 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: #14344 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Sun, 31 Mar 2024 18:45:05 +0200
parents 172f30203d25
children 63e3334bcadb
comparison
equal deleted inserted replaced
34704:60194371609e 34705:159d598e6781
2256 if (!ins_compl_active()) 2256 if (!ins_compl_active())
2257 { 2257 {
2258 saveRedobuff(&save_redo); 2258 saveRedobuff(&save_redo);
2259 did_save_redobuff = TRUE; 2259 did_save_redobuff = TRUE;
2260 } 2260 }
2261 did_filetype = keep_filetype; 2261 curbuf->b_did_filetype = curbuf->b_keep_filetype;
2262 } 2262 }
2263 2263
2264 /* 2264 /*
2265 * Note that we are applying autocmds. Some commands need to know. 2265 * Note that we are applying autocmds. Some commands need to know.
2266 */ 2266 */
2268 filechangeshell_busy = (event == EVENT_FILECHANGEDSHELL); 2268 filechangeshell_busy = (event == EVENT_FILECHANGEDSHELL);
2269 ++nesting; // see matching decrement below 2269 ++nesting; // see matching decrement below
2270 2270
2271 // Remember that FileType was triggered. Used for did_filetype(). 2271 // Remember that FileType was triggered. Used for did_filetype().
2272 if (event == EVENT_FILETYPE) 2272 if (event == EVENT_FILETYPE)
2273 did_filetype = TRUE; 2273 curbuf->b_did_filetype = TRUE;
2274 2274
2275 tail = gettail(fname); 2275 tail = gettail(fname);
2276 2276
2277 // Find first autocommand that matches 2277 // Find first autocommand that matches
2278 CLEAR_FIELD(patcmd); 2278 CLEAR_FIELD(patcmd);
2377 if (!autocmd_busy) 2377 if (!autocmd_busy)
2378 { 2378 {
2379 restore_search_patterns(); 2379 restore_search_patterns();
2380 if (did_save_redobuff) 2380 if (did_save_redobuff)
2381 restoreRedobuff(&save_redo); 2381 restoreRedobuff(&save_redo);
2382 did_filetype = FALSE; 2382 curbuf->b_did_filetype = FALSE;
2383 while (au_pending_free_buf != NULL) 2383 while (au_pending_free_buf != NULL)
2384 { 2384 {
2385 buf_T *b = au_pending_free_buf->b_next; 2385 buf_T *b = au_pending_free_buf->b_next;
2386 2386
2387 vim_free(au_pending_free_buf); 2387 vim_free(au_pending_free_buf);
2419 // are deleted. 2419 // are deleted.
2420 if (event == EVENT_BUFWIPEOUT && buf != NULL) 2420 if (event == EVENT_BUFWIPEOUT && buf != NULL)
2421 aubuflocal_remove(buf); 2421 aubuflocal_remove(buf);
2422 2422
2423 if (retval == OK && event == EVENT_FILETYPE) 2423 if (retval == OK && event == EVENT_FILETYPE)
2424 au_did_filetype = TRUE; 2424 curbuf->b_au_did_filetype = TRUE;
2425 2425
2426 return retval; 2426 return retval;
2427 } 2427 }
2428 2428
2429 # ifdef FEAT_EVAL 2429 # ifdef FEAT_EVAL