From 5e1fa025534b92b7da908f0acaee84663f8ea71b Mon Sep 17 00:00:00 2001 From: GyouzaRu <94124025+GyouzaRu@users.noreply.github.com> Date: Sun, 10 Dec 2023 19:22:00 +0800 Subject: [PATCH] Fix: Buffer is not 'modifiable' (#1677) --- lua/cmp/view/custom_entries_view.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lua/cmp/view/custom_entries_view.lua b/lua/cmp/view/custom_entries_view.lua index a5eca58b1..dc7564d70 100644 --- a/lua/cmp/view/custom_entries_view.lua +++ b/lua/cmp/view/custom_entries_view.lua @@ -140,7 +140,13 @@ custom_entries_view.open = function(self, offset, entries) end end end - vim.api.nvim_buf_set_lines(entries_buf, 0, -1, false, lines) + if vim.bo[entries_buf].modifiable == false then + vim.bo[entries_buf].modifiable = true + vim.api.nvim_buf_set_lines(entries_buf, 0, -1, false, lines) + vim.bo[entries_buf].modifiable = false + else + vim.api.nvim_buf_set_lines(entries_buf, 0, -1, false, lines) + end vim.api.nvim_buf_set_option(entries_buf, 'modified', false) local width = 0 @@ -264,7 +270,13 @@ custom_entries_view.draw = function(self) table.insert(texts, table.concat(text, '')) end end - vim.api.nvim_buf_set_lines(entries_buf, topline, botline, false, texts) + if vim.bo[entries_buf].modifiable == false then + vim.bo[entries_buf].modifiable = true + vim.api.nvim_buf_set_lines(entries_buf, topline, botline, false, texts) + vim.bo[entries_buf].modifiable = false + else + vim.api.nvim_buf_set_lines(entries_buf, topline, botline, false, texts) + end vim.api.nvim_buf_set_option(entries_buf, 'modified', false) if api.is_cmdline_mode() then