Skip to content

Conversation

@BurntSushi
Copy link
Member

PR #21549 introduced a subtle overflow bug that seemed impossible, but
can empirically happen. This PR fixes it by saturating to zero.

I did try to write a regression test for this, but couldn't manage it.
Instead, I'll attach before-and-after screen recordings.

@BurntSushi BurntSushi added bug Something isn't working server Related to the LSP server ty Multi-file analysis & type inference labels Nov 21, 2025
@BurntSushi
Copy link
Member Author

Before:

2025-11-21T13.58.50-05.00.mp4

After:

2025-11-21T14.01.48-05.00.mp4

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 21, 2025

Diagnostic diff on typing conformance tests

No changes detected when running ty on typing conformance tests ✅

PR #21549 introduced a subtle overflow bug that seemed impossible, but
can empirically happen. This PR fixes it by saturating to zero.

I did try to write a regression test for this, but couldn't manage it.
Instead, I'll attach before-and-after screen recordings.
@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 21, 2025

mypy_primer results

Changes were detected when running on open source projects
scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/build/wheel.py:98:20: error[no-matching-overload] No overload of bound method `__init__` matches arguments
- Found 45 diagnostics
+ Found 44 diagnostics

No memory usage changes detected ✅

@astral-sh-bot
Copy link

astral-sh-bot bot commented Nov 21, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I wonder if this is getting confused about utf8 vs utf16... 😨

@BurntSushi BurntSushi merged commit 438ef33 into main Nov 21, 2025
66 of 67 checks passed
@BurntSushi BurntSushi deleted the ag/fix-subtraction branch November 21, 2025 20:07
@RasmusNygren
Copy link
Contributor

RasmusNygren commented Nov 21, 2025

Oh that was sloppy by me, not sure how I didn't see that in the playground. 🤔

This seems to (at the very least) happen when the cursor is in the middle of a token at the start of the file. This seems to reproduce it:

let builder = completion_test_builder(
            "\
f<CURSOR>oo = 1
",
);
builder.build();

@Gankra
Copy link
Contributor

Gankra commented Nov 21, 2025

Oh I see, are we subtracting the size of the whole token from the cursor, rather than token-up-to-the-cursor?

@RasmusNygren
Copy link
Contributor

We do get the range for the entire token

Some(source[last.range()].to_string())

The subtraction is probably a bit off in general then and there might be some other scenarios where we don't suppress suggestions (even though we should) if the cursor is not at the end of the current token. Had a quick check but couldn't figure out a test case that trigger such a scenario even though I feel like they must exist. I'll have a think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working server Related to the LSP server ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants