summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-09-17 08:20:39 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-09-17 08:20:39 -0400
commit1dc29ed14b6d1924889166b3d26666d2d9cac9fc (patch)
tree3c9163b125db0eb4638f79812aad443479c27877 /lua
parent7d3e93e7b4de0e830c7e5058b809e3f783b42ec5 (diff)
fix: Don't write to invalid buffers
Diffstat (limited to 'lua')
-rw-r--r--lua/telescope/pickers.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua
index bf88b63..7ab903e 100644
--- a/lua/telescope/pickers.lua
+++ b/lua/telescope/pickers.lua
@@ -324,6 +324,10 @@ function Picker:find()
self.manager = pickers.entry_manager(
self.max_results,
vim.schedule_wrap(function(index, entry)
+ if not vim.api.nvim_buf_is_valid(results_bufnr) then
+ return
+ end
+
local row = self:get_row(index)
-- If it's less than 0, then we don't need to show it at all.
@@ -585,6 +589,10 @@ function Picker:set_selection(row)
local status = state.get_status(self.prompt_bufnr)
local results_bufnr = status.results_bufnr
+ if not vim.api.nvim_buf_is_valid(results_bufnr) then
+ return
+ end
+
-- Handle adding '> ' to beginning of selections
if self._selection_row then
local old_selection = a.nvim_buf_get_lines(results_bufnr, self._selection_row, self._selection_row + 1, false)[1]