Skip to content

Commit

Permalink
feat(utils/window): use api function to get text height
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Oct 20, 2024
1 parent 4ae4152 commit b913f9c
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions lua/care/utils/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,23 +186,7 @@ function Window:get_data()
data.has_border = data.border and data.border ~= "none"
data.width_with_border = data.width_without_border + (data.has_border and 2 or 0)
data.height_with_border = data.height_without_border + (data.has_border and 2 or 0)
if not vim.api.nvim_get_option_value("wrap", { win = self.winnr }) then
data.total_lines = vim.api.nvim_buf_line_count(self.buf)
else
local height = 0
for _, line in ipairs(vim.api.nvim_buf_get_lines(self.buf, 0, -1, false)) do
local wrapped_width = vim.fn.strdisplaywidth(line) - data.width_without_border
height = height + 1
if wrapped_width > 0 then
height = height
+ math.max(
1,
math.ceil(wrapped_width / (data.width_without_border - vim.fn.strdisplaywidth(vim.o.showbreak)))
)
end
end
data.total_lines = height
end
data.total_lines = vim.api.nvim_win_text_height(self.winnr, {}).all
return data
end

Expand Down

0 comments on commit b913f9c

Please sign in to comment.