Skip to content

Commit d6cc6f9

Browse files
Proper handing of raw strings in rust (#2681)
Fixes #2678 ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet
1 parent ca31335 commit d6cc6f9

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"aaa"
2+
r#"bbb"#
3+
r##"ccc"##
4+
---
5+
6+
[#1 Content] =
7+
[#1 Removal] =
8+
[#1 Domain] = 0:0-0:5
9+
>-----<
10+
0| "aaa"
11+
12+
[#1 Insertion delimiter] = " "
13+
14+
15+
[#2 Content] =
16+
[#2 Removal] =
17+
[#2 Domain] = 1:0-1:8
18+
>--------<
19+
1| r#"bbb"#
20+
21+
[#2 Insertion delimiter] = " "
22+
23+
24+
[#3 Content] =
25+
[#3 Removal] =
26+
[#3 Domain] = 2:0-2:10
27+
>----------<
28+
2| r##"ccc"##
29+
30+
[#3 Insertion delimiter] = " "
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"aaa"
2+
r#"bbb"#
3+
r##"ccc"##
4+
---
5+
6+
[#1 Content] =
7+
[#1 Removal] =
8+
[#1 Domain] = 0:1-0:4
9+
>---<
10+
0| "aaa"
11+
12+
[#1 Insertion delimiter] = " "
13+
14+
15+
[#2 Content] =
16+
[#2 Removal] =
17+
[#2 Domain] = 1:3-1:6
18+
>---<
19+
1| r#"bbb"#
20+
21+
[#2 Insertion delimiter] = " "
22+
23+
24+
[#3 Content] =
25+
[#3 Removal] =
26+
[#3 Domain] = 2:4-2:7
27+
>---<
28+
2| r##"ccc"##
29+
30+
[#3 Insertion delimiter] = " "

packages/common/src/scopeSupportFacets/rust.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
77
export const rustScopeSupport: LanguageScopeSupportFacetMap = {
88
ifStatement: supported,
99
disqualifyDelimiter: supported,
10+
"string.singleLine": supported,
11+
"textFragment.string.singleLine": supported,
1012
};

queries/rust.scm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
(if_let_expression)
66
] @ifStatement
77

8+
;;!! "hello"
89
(
9-
[
10-
(raw_string_literal)
11-
(string_literal)
12-
] @string @textFragment
10+
(string_literal) @string @textFragment
1311
(#child-range! @textFragment 0 -1 true true)
1412
)
1513

14+
;;!! r#"foobar"#
15+
(
16+
(raw_string_literal) @string @textFragment
17+
(#shrink-to-match! @textFragment "r#+\"(?<keep>.*)\"#+")
18+
19+
)
20+
1621
[
1722
(line_comment)
1823
(block_comment)

0 commit comments

Comments
 (0)