Skip to content

Commit

Permalink
fix: Fixed Inline math padding issues in LaTeX
Browse files Browse the repository at this point in the history
Ref: #177
  • Loading branch information
OXY2DEV committed Nov 8, 2024
1 parent 5c42f0e commit 03967fb
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions lua/markview/renderers/latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,14 +409,16 @@ latex.inline = function (buffer, item)
hl_mode = "combine"
});

vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_start, #item.text[1], {
undo_restore = false, invalidate = true,
if #item.text > 1 then
vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_start, range.col_start + #item.text[1], {
undo_restore = false, invalidate = true,

virt_text_pos = "inline",
virt_text = {
{ config.padding_right or "", utils.set_hl(config.padding_right_hl or config.hl) }
}
});
virt_text_pos = "inline",
virt_text = {
{ config.padding_right or "", utils.set_hl(config.padding_right_hl or config.hl) }
}
});
end

vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_start, range.col_start, {
undo_restore = false, invalidate = true,
Expand All @@ -440,17 +442,19 @@ latex.inline = function (buffer, item)
hl_mode = "combine"
});

vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_end, math.min(#item.text[#item.text], range.col_start), {
undo_restore = false, invalidate = true,
if #item.text > 1 then
vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_end, 0, {
undo_restore = false, invalidate = true,

virt_text_pos = "inline",
virt_text = {
{ config.padding_left or "", utils.set_hl(config.padding_left_hl or config.hl) },
}
});
virt_text_pos = "inline",
virt_text = {
{ config.padding_left or "", utils.set_hl(config.padding_left_hl or config.hl) },
}
});
end

for l = 1, #item.text - 2 do
vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_start + l, math.min(#item.text[l + 1], range.col_start), {
vim.api.nvim_buf_set_extmark(buffer, latex.ns("injections"), range.row_start + l, 0, {
undo_restore = false, invalidate = true,

virt_text_pos = "inline",
Expand Down

0 comments on commit 03967fb

Please sign in to comment.