From abb3706974ca0b5086110d8f1b0e90daebff758f Mon Sep 17 00:00:00 2001 From: Michael Lingelbach Date: Thu, 23 Dec 2021 15:20:28 -0500 Subject: fix: only attempt to attach to valid bufnames (#1598) * Check that a bufname begins with a filesystem root specifier such as a drive letter (Windows) or "/" (Unix) * Unify with check that buf name is not "" or nil --- lua/lspconfig/util.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lua/lspconfig/util.lua') diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 05d844ae..11586d50 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -19,6 +19,14 @@ M.default_config = { -- global on_setup hook M.on_setup = nil +function M.bufname_valid(bufname) + if bufname and bufname ~= '' and (bufname:match '^([a-zA-Z]:).*' or bufname:match '^/') then + return true + else + return false + end +end + function M.validate_bufnr(bufnr) validate { bufnr = { bufnr, 'n' }, -- cgit v1.2.3-70-g09d2