Skip to content

Commit

Permalink
fix: bounds check call to screenpos (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlubas committed Apr 22, 2024
1 parent f3a40c7 commit 2739a9d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/output_window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ local M = {}
---@return number
M.calculate_window_position = function(buf_line)
local win = vim.api.nvim_get_current_win()
local pos = vim.fn.screenpos(win, buf_line, 0)
local num_lines = vim.fn.line("$")
local pos = vim.fn.screenpos(win, math.min(num_lines, buf_line), 0)
local win_off = vim.fn.getwininfo(win)[1].winrow

return pos.row - (win_off - 1)
Expand Down

0 comments on commit 2739a9d

Please sign in to comment.