-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[playground]: Fix non‑BMP code point handling in quick‑fixes and markers
#20526
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
Conversation
MichaReiser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I think I'd prefer to handle this the same way as we do in ty: That is, implement the conversion in ruff_wasm. The benefit of this is that downstream ruff_wasm users also benefit from this change (I suspect that most downstream users use JS too and would require the exact same conversion).
See
ruff/crates/ty_wasm/src/lib.rs
Lines 88 to 92 in a9b6618
| pub fn new( | |
| root: &str, | |
| position_encoding: PositionEncoding, | |
| options: JsValue, | |
| ) -> Result<Workspace, Error> { |
|
crates/ruff_wasm/src/lib.rs
Outdated
| let start_loc = source_code.source_location(range.start(), PositionEncoding::Utf16); | ||
| let end_loc = source_code.source_location(range.end(), PositionEncoding::Utf16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works but it will break existing clients that assumed UTF8.
I suggest adding positionEncoding a new argument to new (similar to ty) and storing it on the Workspace and then using it here.
This allows each user to use the encoding that best suits their use case.
2376834 to
18d3565
Compare
MichaReiser
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. this is great
Summary
Fixes #16266
Updated the playground to convert UTF‑32 (code point) columns from the WASM diagnostics/fixes into Monaco’s UTF‑16 columns when constructing both quick‑fix edit ranges and diagnostic markers in
playground/ruff/src/Editor/SourceEditor.tsx.With this change, applying the
C408quick fix ondict(𠤪=1)now correctly yields{"𠤪": 1}without leaving a stray).