Skip to content

Fix ide-assists raw_string suffix fail #19622

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

Merged
merged 2 commits into from
Apr 22, 2025

Conversation

A4-Tacks
Copy link
Contributor

@A4-Tacks A4-Tacks commented Apr 18, 2025

Fixes #19621
Fixes #19625

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 18, 2025
@A4-Tacks A4-Tacks changed the title Support ide-assists raw_string suffix Fix ide-assists raw_string suffix fail Apr 20, 2025
Comment on lines +39 to +41
let range = token.syntax().text_range();
let suffix = string_suffix(token.text()).unwrap_or_default();
let range = TextRange::new(range.start(), range.end() - TextSize::of(suffix));
Copy link
Member

Choose a reason for hiding this comment

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

Can we add this stuff as a method on IsString? text_range_with_quotes or something like that

Copy link
Member

Choose a reason for hiding this comment

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

Actually instead of string_suffix we can make use of the IsString::quote_offsets function here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about char? Is there anything similar

Copy link
Member

@Veykril Veykril Apr 22, 2025

Choose a reason for hiding this comment

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

No there isn't, we should probably implement IsString for Char as well though (and then consider renaming the trait). I guess the RAW_PREFIX stuff doesn't make sense on it but that's not too much of an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that IsString::quote_offsets is not just extracting suffixes, but extracting quotation marks, which can be difficult to handle for #

Copy link
Contributor Author

Choose a reason for hiding this comment

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

string_suffix(r###"r##"x"##i32"###) -> "i32"
QuoteOffsets::new(r###"r##"x"##i32"###) -> range "r##\"", range "\"##i32", and range "x"

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, well 'lets merge as is then

@Veykril Veykril added this pull request to the merge queue Apr 22, 2025
@Veykril
Copy link
Member

Veykril commented Apr 22, 2025

Thanks!

Merged via the queue into rust-lang:master with commit 669a308 Apr 22, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
3 participants