aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-03-30 11:35:13 +0100
committerGitHub <noreply@github.com>2023-03-30 11:35:13 +0100
commite5fa2e3a5d0f120c0b957b4643ea63a807ba377b (patch)
tree8d12128e468073d0db693f96dda0fd8ec522059a /src
parent61e54f26361b2e7d08eabde9a4cbf42aaa41683b (diff)
downloadrneovim-e5fa2e3a5d0f120c0b957b4643ea63a807ba377b.tar.gz
rneovim-e5fa2e3a5d0f120c0b957b4643ea63a807ba377b.tar.bz2
rneovim-e5fa2e3a5d0f120c0b957b4643ea63a807ba377b.zip
fix(autocmd): handle recursion for force set (#22820)
Diffstat (limited to 'src')
-rw-r--r--src/nvim/autocmd.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index b488dd9f8f..2e83260a40 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -2761,9 +2761,9 @@ void do_autocmd_focusgained(bool gained)
void do_filetype_autocmd(buf_T *buf, bool force)
{
- static bool recursive = false;
+ static int ft_recursive = 0;
- if (recursive && !force) {
+ if (ft_recursive > 0 && !force) {
return; // disallow recursion
}
@@ -2774,12 +2774,12 @@ void do_filetype_autocmd(buf_T *buf, bool force)
// been checked to be safe.
secure = 0;
- recursive = true;
+ ft_recursive++;
did_filetype = true;
// Only pass true for "force" when it is true or
// used recursively, to avoid endless recurrence.
apply_autocmds(EVENT_FILETYPE, buf->b_p_ft, buf->b_fname, force, buf);
- recursive = false;
+ ft_recursive--;
// Just in case the old "buf" is now invalid
if (varp != &(buf->b_p_ft)) {