From 729cdb4c8f10ea6d926d47937541591518ce4732 Mon Sep 17 00:00:00 2001 From: Kurama622 Date: Sun, 4 May 2025 01:30:47 +0800 Subject: [PATCH] fix: handle empty buffer name in completion retrieval - Add early return if buffer name is empty --- lua/codeium/blink.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/codeium/blink.lua b/lua/codeium/blink.lua index d0cd9c8..c198063 100644 --- a/lua/codeium/blink.lua +++ b/lua/codeium/blink.lua @@ -112,6 +112,12 @@ function M:get_completions(ctx, callback) local line_ending = util.get_newline(bufnr) local line_ending_len = utf8len(line_ending) local editor_options = util.get_editor_options(bufnr) + local buf_name = vim.api.nvim_buf_get_name(bufnr) + + if buf_name == "" then + callback(nil) + return function() end + end -- We need to calculate the number of bytes prior to the current character, -- that starts with all the prior lines @@ -157,7 +163,7 @@ function M:get_completions(ctx, callback) editor_language = filetype, language = language, cursor_position = { row = cursor[1] - 1, col = cursor[2] }, - absolute_uri = util.get_uri(vim.api.nvim_buf_get_name(bufnr)), + absolute_uri = util.get_uri(buf_name), workspace_uri = util.get_uri(util.get_project_root()), line_ending = line_ending, cursor_offset = cursor_offset,