vscode-black-formatter: Black does not format correctly strings containing emojis
It seems that this extension does not handle correctly formatting strings containing emojis when formatting from vscode. Formatting the file with the black command via cli works correctly.
Examples:
before
s = 'π'
x = 'foo'
after
s = ""'
x = "foo"
or
s = 'π€΅ hi!'
after
s = "π€΅ hi"'
Investigating a bit, it seems that the positions sent back from the language server to the client count the emojis as a single character while the visual studio code editor doesnβt, as for the first example the line edits relative to the line 0 are 0:4-0:5, new_text='"'
and 0:6-0:7, new_text='"'
, but the second one seems to replace something other than the second '
. Tampering with the server code and setting 0:7-0:8
to the second edit fixes the problem.
Tested on Windows 10.
About this issue
- Original URL
- State: closed
- Created 7 months ago
- Reactions: 4
- Comments: 18 (8 by maintainers)
Verification steps:
something.py
:I have a potential fix for this, please give this a try: https://github.com/microsoft/vscode-black-formatter/actions/runs/7426466173/artifacts/1150857594