Skip to content

Commit

Permalink
fix(promo): don't add whitespace to empty lines (#852)
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed May 15, 2023
1 parent b85fe10 commit a7291f4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lua/neorg/modules/core/promo/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,20 @@ module.public = {
end
local function buffer_set_line_indent(start_row, new_indent)
local n_whitespace =
count_leading_whitespace(vim.api.nvim_buf_get_lines(buffer, start_row, start_row + 1, true)[1])
return vim.api.nvim_buf_set_text(buffer, start_row, 0, start_row, n_whitespace, { (" "):rep(new_indent) })
local line = vim.api.nvim_buf_get_lines(buffer, start_row, start_row + 1, true)[1]
if line:match("^%s*$") then
return
end
return vim.api.nvim_buf_set_text(
buffer,
start_row,
0,
start_row,
count_leading_whitespace(line),
{ (" "):rep(new_indent) }
)
end
-- Treesitter node helpers
Expand Down

0 comments on commit a7291f4

Please sign in to comment.