Skip to content

Conversation

@danparizher
Copy link
Contributor

@danparizher danparizher commented Sep 23, 2025

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 C408 quick fix on dict(𠤪=1) now correctly yields {"𠤪": 1} without leaving a stray ).

@MichaReiser MichaReiser added the playground A playground-specific issue label Sep 23, 2025
Copy link
Member

@MichaReiser MichaReiser left a 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

pub fn new(
root: &str,
position_encoding: PositionEncoding,
options: JsValue,
) -> Result<Workspace, Error> {

@github-actions
Copy link
Contributor

github-actions bot commented Sep 23, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Comment on lines 233 to 234
let start_loc = source_code.source_location(range.start(), PositionEncoding::Utf16);
let end_loc = source_code.source_location(range.end(), PositionEncoding::Utf16);
Copy link
Member

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.

Copy link
Member

@MichaReiser MichaReiser left a 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

@MichaReiser MichaReiser merged commit 3e1e02e into astral-sh:main Sep 24, 2025
36 checks passed
@danparizher danparizher deleted the fix-16266 branch September 24, 2025 11:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

playground A playground-specific issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Playground counts each non-BMP code point as two code points

2 participants