Skip to content

Commit 3415a61

Browse files
committed
fix(ui): properly wrap ui elements on small screens. Fixes #92
1 parent c0c2e1b commit 3415a61

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

lua/lazy/view/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function M.show(mode)
122122
callback = close,
123123
})
124124

125-
local render = Render.new(buf, win, 2)
125+
local render = Render.new(buf, win, 2, opts.width)
126126
local update = Util.throttle(Config.options.ui.throttle, function()
127127
if buf and vim.api.nvim_buf_is_valid(buf) then
128128
vim.bo[buf].modifiable = true

lua/lazy/view/render.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ local Text = require("lazy.view.text")
1919
---@field _details? string
2020
local M = setmetatable({}, { __index = Text })
2121

22-
function M.new(buf, win, padding)
22+
function M.new(buf, win, padding, wrap)
2323
local self = setmetatable({}, { __index = M })
2424
self.buf = buf
2525
self.win = win
2626
self.padding = padding or 0
27+
self.wrap = wrap
2728
return self
2829
end
2930

lua/lazy/view/text.lua

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local Config = require("lazy.core.config")
66
---@class Text
77
---@field _lines TextSegment[][]
88
---@field padding number
9+
---@field wrap number
910
local Text = {}
1011

1112
function Text.new()
@@ -37,6 +38,9 @@ function Text:append(str, hl, opts)
3738
if l > 1 then
3839
self:nl()
3940
end
41+
if self:col() > 0 and self:col() + vim.fn.strwidth(line) + self.padding > self.wrap then
42+
self:nl()
43+
end
4044
table.insert(self._lines[#self._lines], {
4145
str = line,
4246
hl = hl,

0 commit comments

Comments
 (0)