Skip to content

Commit

Permalink
fix: check if bufdata.last_win != nil (#356)
Browse files Browse the repository at this point in the history
When opening nvim in diffview (`nvim -c DiffviewOpen`) and then toggeling aerial,
aerial errors when trying to call `vim.api.nvim_win_is_valid(bufdata.last_win)`
as bufdata.last_win == nil. This change adds a check and returns in case of a nil
value.

Co-authored-by: Linus Boehm <linusboehm@gmail.com>
  • Loading branch information
linusboehm and Linus Boehm committed Mar 28, 2024
1 parent 51a0794 commit 24ebaca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/aerial/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,9 @@ M.center_symbol_in_view = function(buffer)
return
end
local bufdata = data.get_or_create(bufnr)
if not bufdata.last_win then
return
end
if vim.api.nvim_buf_is_valid(aer_bufnr) and vim.api.nvim_win_is_valid(bufdata.last_win) then
local last_position = bufdata.positions[bufdata.last_win]
if last_position then
Expand Down

0 comments on commit 24ebaca

Please sign in to comment.