Wansmer / langmapper.nvim

A plugin that makes Neovim more friendly to non-English input methods 🤝
MIT License
128 stars 7 forks source link

fix: properly check string length #7

Closed danilshvalov closed 1 year ago

danilshvalov commented 1 year ago

Hi, thanks for this wonderful plugin! To check the length of a string, you should use the function vim.fn.strchars instead of the function vim.fn. strdisplaywidth, since the function vim.fn.strdisplaywidth returns not the size of the string, but its width on the screen. For example, due to the use of vim.fn.strdisplaywidth, I get an error

Langmapper: "default_layout" and "layout" contain different number of characters. Check your config for "ru".

Еще раз спасибо за плагин, приятно видеть русскоговорящих в сообществе Neovim :)

Wansmer commented 1 year ago

Привет! Спасибо за PR. Не знал, что vim.fn.strchars правильно работает с многобайтовыми символами.

Можно посмотреть на строки, которые вызывали ошибку?

danilshvalov commented 1 year ago

Строки были из дефолтного конфига, то есть эти:

default_layout = [[~QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?`qwertyuiop[]asdfghjkl;'zxcvbnm,./]]
layout         = [[ËЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,ёйцукенгшщзхъфывапролджэячсмитьбю.]]