markdown.nvim
markdown.nvim copied to clipboard
[BUG]: The `table_style` setting incorrectly calculated the text length inside the table.
trafficstars
After I tried the plugin, I found that when the cell text length of each column of the table is the same, the plugin will add lines above and below the table.
For ascii characters, this calculation is correct.
But for other characters, such as Chinese, this is not so good.
Because for Chinese characters, Lua will count the length of the character as 3, such as: 行.
However, with a mono font, 行 actually takes up 2 characters of width.
For example, the following table will add lines, but it actually doesn’t look good:
| 列1 | 列2 | 列3 |
| ---- | ---- | ---- |
| 行1 | 2 | 3 |
| 行2 | 2 | 3 |
| 行3 | 2 | 3 |
Although the following table has the same width, lines cannot be added:
| 列1 | 列2 | 列3 |
| --- | --- | --- |
| 行1 | 2 | 3 |
| 行2 | 2 | 3 |
| 行3 | 2 | 3 |
Perhaps should use the strwidth function to calculate text length:
vim.fn.strwidth("行") = 2