Skip to content

Conversation

@TheLeoP
Copy link
Member

@TheLeoP TheLeoP commented Dec 29, 2025

Fixes #1901

This includes a small shim (in each of the affected modules) that uses the new signature on Neovim >= 0.11. Let me know if a different approach would be preferred.

end

-- TODO: Remove after compatibility with Neovim=0.10 is dropped
H.str_byteindex = vim.fn.has('nvim-0.11') == 1 and function(s, i) return vim.str_byteindex(s, 'utf-32', i) end
Copy link
Member Author

@TheLeoP TheLeoP Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had my doubts about whether or not H.str_byteindex should only be defined conditionally inside of the below check for vim.fn.has('nvim-0.10') == 0 as it is the only usage of vim.str_byteindex in this module. But, in the end decided against it because it seemed cleaner.

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

Successfully merging this pull request may close these issues.

Improve usage of vim.str_utfindex and vim.str_byteindex

1 participant