Skip to content
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

Proper handing of raw strings in rust #2681

Merged
merged 2 commits into from
Nov 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions data/fixtures/scopes/rust/string.singleLine.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"aaa"
r#"bbb"#
r##"ccc"##
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:0-0:5
>-----<
0| "aaa"

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] =
[#2 Domain] = 1:0-1:8
>--------<
1| r#"bbb"#

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] =
[#3 Domain] = 2:0-2:10
>----------<
2| r##"ccc"##

[#3 Insertion delimiter] = " "
30 changes: 30 additions & 0 deletions data/fixtures/scopes/rust/textFragment.string.singleLine.scope
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"aaa"
r#"bbb"#
r##"ccc"##
---

[#1 Content] =
[#1 Removal] =
[#1 Domain] = 0:1-0:4
>---<
0| "aaa"

[#1 Insertion delimiter] = " "


[#2 Content] =
[#2 Removal] =
[#2 Domain] = 1:3-1:6
>---<
1| r#"bbb"#

[#2 Insertion delimiter] = " "


[#3 Content] =
[#3 Removal] =
[#3 Domain] = 2:4-2:7
>---<
2| r##"ccc"##

[#3 Insertion delimiter] = " "
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/rust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
export const rustScopeSupport: LanguageScopeSupportFacetMap = {
ifStatement: supported,
disqualifyDelimiter: supported,
"string.singleLine": supported,
"textFragment.string.singleLine": supported,
};
13 changes: 9 additions & 4 deletions queries/rust.scm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
(if_let_expression)
] @ifStatement

;;!! "hello"
(
[
(raw_string_literal)
(string_literal)
] @string @textFragment
(string_literal) @string @textFragment
(#child-range! @textFragment 0 -1 true true)
)

;;!! r#"foobar"#
(
(raw_string_literal) @string @textFragment
(#shrink-to-match! @textFragment "r#+\"(?<keep>.*)\"#+")

)

[
(line_comment)
(block_comment)
Expand Down
Loading