Skip to content

StatusView shows incorrect number of columns #300

@richiefreedom

Description

@richiefreedom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions