Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StatusView shows incorrect number of columns #300

Open
richiefreedom opened this issue May 3, 2022 · 0 comments
Open

StatusView shows incorrect number of columns #300

richiefreedom opened this issue May 3, 2022 · 0 comments

Comments

@richiefreedom
Copy link
Contributor

The number of columns shown by StatusView is correct only for English texts. Any language that needs more than 1 byte to represent characters in UTF-8 results to an incorrect column number.

This works the described way because the column is obtained simply by calling the method Doc:get_selection, which works with plain bytes instead of runes.

A simple fix to the problem is counting of runes with something like:

function common.utf8_len(text)
  local len = 0
  for char in common.utf8_chars(text) do len = len + 1 end
  return len
end

So, the column in StatusView:get_items() can be recomputed the following way:

col = common.utf8_len(dv.doc:get_text(line, 1, line, col)) + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant