Skip to content

fix: use non-deprecated overload of vim.str_utfindex#1348

Merged
L3MON4D3 merged 2 commits intoL3MON4D3:masterfrom
MariaSolOs:deprecated
Jun 3, 2025
Merged

fix: use non-deprecated overload of vim.str_utfindex#1348
L3MON4D3 merged 2 commits intoL3MON4D3:masterfrom
MariaSolOs:deprecated

Conversation

@MariaSolOs
Copy link
Copy Markdown
Contributor

The current use of vim.str_utfindex was deprecated in neovim/neovim#30915. Now the encoding parameter is required and return value is an integer (instead of the table from the deprecated version corresponding to the utf-32 and utf-16 encodings).

@leiserfg
Copy link
Copy Markdown
Contributor

IMHO it would be better to have local function that maps to the old str_utfindex if version is lower than 0.11 or a wrapper of the new one that gets the same args as the old one in >=0.11. Cause we try to keep backward compatibility.

@leiserfg
Copy link
Copy Markdown
Contributor

Why does bytecol_to_utfcol returns now 3 elements instead of 2?

@MariaSolOs
Copy link
Copy Markdown
Contributor Author

Why does bytecol_to_utfcol returns now 3 elements instead of 2?

It should not. Thanks for catching that.

@MariaSolOs MariaSolOs force-pushed the deprecated branch 2 times, most recently from 9a2e962 to 484c002 Compare May 26, 2025 16:12
@L3MON4D3
Copy link
Copy Markdown
Owner

L3MON4D3 commented Jun 2, 2025

Hi :)
It seems like our code was a bit misleading, the pre-0.11 str_utfindex returns utf32_index, utf16_index, not the other way around (see here).
Since we only really need the utf32-index in both of these cases, could you extract the added version-check logic into one function in util/util.lua, maybe str_utf32index, and call that in both situations?

I'm also fine with me doing this, just let me know :D

@MariaSolOs
Copy link
Copy Markdown
Contributor Author

MariaSolOs commented Jun 2, 2025

the pre-0.11 str_utfindex returns utf32_index, utf16_index, not the other way around (see here).

Oh yes, that has been the code I've been referring to but I clearly switched the order 🤦🏻‍♀️

Since we only really need the utf32-index in both of these cases, could you extract the added version-check logic into one function in util/util.lua, maybe str_utf32index, and call that in both situations?

I can do that, but the existing code does seem to use the utf16-index, that's what bytecol_to_utfcol returns. Am I missing something?
nvm, I realized that bytecol_to_utfcol is unused.

I'm also fine with me doing this, just let me know :D

I'm happy to do this, no worries :)

@L3MON4D3
Copy link
Copy Markdown
Owner

L3MON4D3 commented Jun 3, 2025

Alright, looks good :D
Thank You for the addition!

@L3MON4D3 L3MON4D3 merged commit 776a29c into L3MON4D3:master Jun 3, 2025
@MariaSolOs MariaSolOs deleted the deprecated branch June 3, 2025 23:19
@MariaSolOs
Copy link
Copy Markdown
Contributor Author

Alright, looks good :D Thank You for the addition!

Thanks to you for the review!

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.

3 participants