aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua
diff options
context:
space:
mode:
authoraltermo <107814000+altermo@users.noreply.github.com>2024-11-18 15:40:51 +0100
committerGitHub <noreply@github.com>2024-11-18 06:40:51 -0800
commite2ad251c8d01726ecd54d925b5280ab32b448c13 (patch)
treeae0843e383b741706685d8ebee939b8d15ed62bb /test/functional/lua
parent40347f6e27f1594797ecb0b268076a94630e4c1b (diff)
downloadrneovim-e2ad251c8d01726ecd54d925b5280ab32b448c13.tar.gz
rneovim-e2ad251c8d01726ecd54d925b5280ab32b448c13.tar.bz2
rneovim-e2ad251c8d01726ecd54d925b5280ab32b448c13.zip
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`.
Diffstat (limited to 'test/functional/lua')
-rw-r--r--test/functional/lua/filetype_spec.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/functional/lua/filetype_spec.lua b/test/functional/lua/filetype_spec.lua
index 574c837f92..b6011d5268 100644
--- a/test/functional/lua/filetype_spec.lua
+++ b/test/functional/lua/filetype_spec.lua
@@ -161,6 +161,18 @@ describe('vim.filetype', function()
end
end
end)
+
+ it('.get_option() cleans up buffer on error', function()
+ api.nvim_create_autocmd('FileType', { pattern = 'foo', command = 'lua error()' })
+
+ local buf = api.nvim_get_current_buf()
+
+ exec_lua(function()
+ pcall(vim.filetype.get_option, 'foo', 'lisp')
+ end)
+
+ eq(buf, api.nvim_get_current_buf())
+ end)
end)
describe('filetype.lua', function()