diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c index 47e1feface..e9202150e6 100644 --- a/src/nvim/runtime.c +++ b/src/nvim/runtime.c @@ -933,6 +933,7 @@ void runtime_search_path_validate(void) } if (!runtime_search_path_valid) { if (!runtime_search_path_ref) { + msg_ext_ui_flush(); // avoid recursion due to UI callback runtime_search_path_free(runtime_search_path); } runtime_search_path = runtime_search_path_build(); diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua index 55af3bdc4c..0c7ea32fd8 100644 --- a/test/functional/core/startup_spec.lua +++ b/test/functional/core/startup_spec.lua @@ -1794,6 +1794,18 @@ describe('runtime:', function() command('edit FTDETECT') eq('SsABab', eval('g:aseq')) end) + + it('no crash for recursive search_path build #39815', function() + clear() + local screen = Screen.new() + fn.jobstart({ + nvim_prog, + '--clean', + '+lua require("vim._core.ui2").enable()', + '+set rtp+=$FOO | set syntax', + }, { term = true, env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } }) + screen:expect({ any = 'syntax', none = 'Process exited 1' }) + end) end) describe('user session', function()