From e2ad251c8d01726ecd54d925b5280ab32b448c13 Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:40:51 +0100 Subject: fix(api): nvim_get_option_value does not clean up on FileType error #31219 Problem: If there's an error in `FileType` autocmd, the filetype get-opt buffer doesn't get cleaned up. Solution: Call `aucmd_restbuf`. --- src/nvim/api/options.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/api/options.c') diff --git a/src/nvim/api/options.c b/src/nvim/api/options.c index bbfd00f2ea..3289daeb6f 100644 --- a/src/nvim/api/options.c +++ b/src/nvim/api/options.c @@ -165,6 +165,14 @@ Object nvim_get_option_value(String name, Dict(option) *opts, Error *err) buf_T *ftbuf = do_ft_buf(filetype, &aco, err); if (ERROR_SET(err)) { + if (ftbuf != NULL) { + // restore curwin/curbuf and a few other things + aucmd_restbuf(&aco); + + assert(curbuf != ftbuf); // safety check + wipe_buffer(ftbuf, false); + } + return (Object)OBJECT_INIT; } -- cgit