Closed kaiphat closed 2 years ago
This patch seems to fix the issue. I don't want to make it into a PR however, because it may be better to create a local function that does this and I cannot take decisions for projects that aren't mine.
diff --git a/lua/align/init.lua b/lua/align/init.lua
index 6b5ef82..3ab2dce 100644
--- a/lua/align/init.lua
+++ b/lua/align/init.lua
@@ -127,7 +127,7 @@ local function align(str, reverse, preview, marks)
local r, c = unpack(pos)
local curr = lines[r - sr + 1]
if c <= target then
- vim.api.nvim_buf_set_lines(0, r - 1, r, true, {string.insert(curr, c, (' '):rep(target - c + (reverse and 1 or 0)))})
+ vim.api.nvim_buf_set_lines(0, r - 1, r, true, {curr:sub(1, c-1) .. (' '):rep(target - c + (reverse and 1 or 0)) .. curr:sub(c)})
else
vim.api.nvim_buf_set_lines(0, r - 1, r, true, {string.sub(curr, 1, target) .. string.sub(curr, c)})
end
The patch looks good to me, I'm not sure why the current implementatuon did not work, but I am willing to either accept a pull request with the changes or I can change it myself.
Honestly I was surprised that it worked for you because according to the lua reference, there is no string.insert
method, so I don't know how you got one. Maybe you have a plugin that is monkey patching the string object.
Anyway, go ahead and change it yourself.
<Space>