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

LuaSnip eating long unicodes #1007

Closed
aloispichler opened this issue Sep 18, 2023 · 8 comments
Closed

LuaSnip eating long unicodes #1007

aloispichler opened this issue Sep 18, 2023 · 8 comments

Comments

@aloispichler
Copy link

aloispichler commented Sep 18, 2023

Consider the snippet

    "emphasize": {
        "prefix": ["\\emph", "*"], 
        "body": "\\emph{${1:$TM_SELECTED_TEXT}}$0",
        "description": "Emphasize text"
    },

to emphasize selected text (this is an example from LaTeX).
If the selected text is 𝔼f-𝔼abc, e.g., then the result is \emph{𝔼f-𝔼a} instead of \emph{𝔼f-𝔼abc}. The reason seems to be that 𝔼 is a long unicode character (u+1d53c). As there are two 𝔼s, LuaSnip ‘eats’ 2 characters. The same happens with other long unicode characters, or with 3 long unicode characters in the selected text, etc.
It seems that LuaSnip somewhere messes the number of characters with the number of bytes.

@L3MON4D3
Copy link
Owner

Ohhhh yup, that's a bug.
I'll look into it

@L3MON4D3
Copy link
Owner

Alriiight, so multibyte characters work now :)
What doesn't is block-select with virtualedit, but I think that we can put off until there is some api-support for just retrieving the visual selection on neovims side.

@aloispichler
Copy link
Author

I've tested it, it works well now, thank you!

@aloispichler
Copy link
Author

Thank you again.
I have tested the behavior today with combined unicodes, as ‖͚ or ∫₀᪲ , and found the same erroneous behavior as described above.

@L3MON4D3
Copy link
Owner

Dammit :|

@L3MON4D3 L3MON4D3 reopened this Sep 23, 2023
@L3MON4D3
Copy link
Owner

Okay, #1013 should work

@L3MON4D3
Copy link
Owner

Finally got the PR into master, we should now have correct behaviour for all kinds of weird edgecases

@aloispichler
Copy link
Author

Seems to work indeed now. Thank you!

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

2 participants