Skip to content

Fix value scope nesting in Typescript #1929

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
Oct 5, 2023
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
Copy link
Member Author

@pokey pokey Oct 4, 2023

Choose a reason for hiding this comment

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

When you say "next value" from the start of the statement, if there's a nested value, you'll get it; if not, you'll end up with the value from the next line. It's a bit opaque, but this test would fail on main

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
languageId: typescript
command:
version: 6
spokenForm: change next value
action:
name: clearAndSetSelection
target:
type: primitive
modifiers:
- type: relativeScope
scopeType: {type: value}
offset: 1
length: 1
direction: forward
usePrePhraseSnapshot: true
initialState:
documentContents: |-
const aaa = 0;
const bbb = 0;
selections:
- anchor: {line: 0, character: 0}
active: {line: 0, character: 0}
marks: {}
finalState:
documentContents: |-
const aaa = 0;
const bbb = ;
selections:
- anchor: {line: 1, character: 12}
active: {line: 1, character: 12}
13 changes: 8 additions & 5 deletions queries/javascript.core.scm
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,14 @@

;; Match nodes at field `value` of their parent node, setting leading delimiter
;; to be the range until the previous named node
(_
(_)? @value.leading.start.endOf
.
value: (_) @value @value.leading.end.startOf
) @_.domain
(
(_
(_)? @value.leading.start.endOf
.
value: (_) @value @value.leading.end.startOf
) @_.domain
(#not-type? @_.domain variable_declarator)
)

;;!! const aaa = {bbb};
;;! ^^^
Expand Down