Skip to content

Commit c21693f

Browse files
chore: remove usage of Str.pad_to method
## Details Only one usage of `Str.pad_to()` remained after recent checkbox change. Replace this usage with an equivalent alternative, cleanup the code, and fix any necessary unit tests.
1 parent 7bf951b commit c21693f

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
[f9badfb](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/f9badfb5907a16c8e0d5f3c157d63bcea2aa555e)
1616
- `code.language_icon` option [#376](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/376)
1717
[8ee2701](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/8ee2701a6c4cdaef7ea0b27c13c26971ae3c9761)
18+
[7bf951b](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/7bf951b8ad93d47b90be290be6fc60da5788ddaa)
1819

1920
### Bug Fixes
2021

lua/render-markdown/health.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.1.12'
8+
M.version = '8.1.13'
99

1010
function M.check()
1111
M.start('version')

lua/render-markdown/lib/str.lua

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ function M.pad(n)
4545
return string.rep(' ', n)
4646
end
4747

48-
---@param target string
49-
---@param s string
50-
---@return string
51-
function M.pad_to(target, s)
52-
return M.pad(M.width(target) - M.width(s))
53-
end
54-
5548
---@param s string
5649
---@param pattern string
5750
---@return Range2[]

lua/render-markdown/render/table.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,12 @@ function Render:delimiter()
247247
end
248248
end)
249249

250-
local text = Str.pad(Str.spaces('start', delim.node.text))
251-
text = text .. border[4] .. table.concat(sections, border[5]) .. border[6]
252-
text = text .. Str.pad_to(delim.node.text, text)
250+
local line = self:append({}, Str.spaces('start', delim.node.text))
251+
self:append(line, border[4] .. table.concat(sections, border[5]) .. border[6], self.table.head)
252+
self:append(line, Str.width(delim.node.text) - Str.line_width(line))
253253

254254
self.marks:add_over('table_border', delim.node, {
255-
virt_text = { { text, self.table.head } },
255+
virt_text = line,
256256
virt_text_pos = 'overlay',
257257
})
258258
end

tests/util.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,13 @@ function M.table.delimiter(sections, padding)
300300
end, widths)
301301
return table.concat(section, '')
302302
end, sections)
303-
local text = '' .. table.concat(parts, '') .. '' .. string.rep(' ', padding or 0)
303+
local line = { { '' .. table.concat(parts, '') .. '', 'RmTableHead' } }
304+
if padding ~= nil then
305+
table.insert(line, { string.rep(' ', padding), 'Normal' })
306+
end
304307
---@type vim.api.keyset.set_extmark
305308
return {
306-
virt_text = { { text, 'RmTableHead' } },
309+
virt_text = line,
307310
virt_text_pos = 'overlay',
308311
}
309312
end

0 commit comments

Comments
 (0)