Skip to content

Fix interior scope tests #2218

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
Feb 2, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
NoContainingScopeError,
TargetRanges,
toCharacterRange,
toLineRange,
Expand All @@ -8,17 +9,23 @@ import { Target } from "../typings/target.types";
export function getTargetRanges(target: Target): TargetRanges {
const interior = (() => {
try {
target.getInteriorStrict().map(getTargetRanges);
return target.getInteriorStrict().map(getTargetRanges);
} catch (error) {
return undefined;
if (error instanceof NoContainingScopeError) {
return undefined;
}
throw error;
}
})();

const boundary = (() => {
try {
target.getBoundaryStrict().map(getTargetRanges);
return target.getBoundaryStrict().map(getTargetRanges);
} catch (error) {
return undefined;
if (error instanceof NoContainingScopeError) {
return undefined;
}
throw error;
}
})();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
0| <div id="root"></div>
>---------------------<

[Interior] = 0:15-0:15
0| <div id="root"></div>
><

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
0| <div id="root"></div>
>---------------------<

[Interior] = 0:15-0:15
0| <div id="root"></div>
><

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ press {user.key}:
1| key(key)
------------<

[Interior] = 1:4-1:12
1| key(key)
>--------<

[Insertion delimiter] = "\n"
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm a bit surprised by this one 🤔

Copy link
Member

@AndreasArvidsson AndreasArvidsson Feb 2, 2024

Choose a reason for hiding this comment

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

Yeah having an interior on the document is a bit meaningless. Appears that interior does not group together with the other ranges though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah interesting point. I'm guessing that's because interior is a target, not a range

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I looked at the code. Totally forgot that "inside file" is the file without any leading or trailing whitespace. I updated the test to capture that fact, but wow, I have never used that feature 😅

Original file line number Diff line number Diff line change
@@ -1,22 +1,40 @@
aaa

aaa

bbb

ccc

---

[Content] =
[Removal] =
[Domain] = 0:0-4:3
0| aaa
>---
1|
[Domain] = 0:0-6:0
0|
>
1| aaa
-----
2|

3| bbb
---
4|

5| ccc
---
6|
<

[Interior] = 1:2-5:3
1| aaa
>---
2|

2| bbb
3| bbb
---
3|
4|

4| ccc
5| ccc
---<

[Insertion delimiter] = "\n"