diff --git a/lua/typescript-tools/protocol/utils.lua b/lua/typescript-tools/protocol/utils.lua index 9e6b1d7..13a591d 100644 --- a/lua/typescript-tools/protocol/utils.lua +++ b/lua/typescript-tools/protocol/utils.lua @@ -242,13 +242,18 @@ end local function is_completing_jsx(bufnr, position) local requested_line = vim.api.nvim_buf_get_lines(bufnr, position.line, position.line + 1, false)[1] local requested_line_until_position = requested_line:sub(1, position.character) - local last_word_before_position = nil - for word in requested_line_until_position:gmatch("%S+") do - last_word_before_position = word - end + local valid_characters_after_start_bracket = "[%w%._$]" - return last_word_before_position ~= nil and last_word_before_position:sub(1, 1) == "<" + for character in requested_line_until_position:reverse():gmatch(".") do + if character == "<" then + return true + end + if not character:match(valid_characters_after_start_bracket) then + return false + end + end + return false end ---@param position LspPosition @@ -265,8 +270,6 @@ local function should_omit_function_snippet_in_context(position, file, request) local body = coroutine.yield() - print(vim.inspect(body)) - return vim.tbl_contains({ "var", "let", "const", "alias" }, body.kind) end