diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName4.yml new file mode 100644 index 0000000000..4335acfe1a --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName4.yml @@ -0,0 +1,23 @@ +languageId: javascript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: for (const aaa of bbb) {} + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: for (const of bbb) {} + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName5.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName5.yml new file mode 100644 index 0000000000..33b8d2db3c --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeName5.yml @@ -0,0 +1,19 @@ +languageId: javascript +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: for (const aaa of bbb) {} + selections: + - anchor: {line: 0, character: 24} + active: {line: 0, character: 24} + marks: {} +thrownError: {name: NoContainingScopeError} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue4.yml new file mode 100644 index 0000000000..c5a2f03666 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue4.yml @@ -0,0 +1,23 @@ +languageId: javascript +command: + version: 6 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: for (const aaa of bbb) {} + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: for (const aaa of ) {} + selections: + - anchor: {line: 0, character: 18} + active: {line: 0, character: 18} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue5.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue5.yml new file mode 100644 index 0000000000..0e6fdfd58e --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/javascript/changeValue5.yml @@ -0,0 +1,19 @@ +languageId: javascript +command: + version: 6 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: for (const aaa of bbb) {} + selections: + - anchor: {line: 0, character: 24} + active: {line: 0, character: 24} + marks: {} +thrownError: {name: NoContainingScopeError} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName.yml new file mode 100644 index 0000000000..2fea916c8c --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + for aaa in bbb: + pass + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: |- + for in bbb: + pass + selections: + - anchor: {line: 0, character: 4} + active: {line: 0, character: 4} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName2.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName2.yml new file mode 100644 index 0000000000..8b7ec1fde0 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeName2.yml @@ -0,0 +1,21 @@ +languageId: python +command: + version: 6 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + for aaa in bbb: + pass + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +thrownError: {name: NoContainingScopeError} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue3.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue3.yml new file mode 100644 index 0000000000..abebf29e89 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue3.yml @@ -0,0 +1,27 @@ +languageId: python +command: + version: 6 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + for aaa in bbb: + pass + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: |- + for aaa in : + pass + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue4.yml b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue4.yml new file mode 100644 index 0000000000..d2888bfc7f --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/recorded/languages/python/changeValue4.yml @@ -0,0 +1,21 @@ +languageId: python +command: + version: 6 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + for aaa in bbb: + pass + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + marks: {} +thrownError: {name: NoContainingScopeError} diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index b5792c461c..9f55bee43d 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -310,6 +310,20 @@ (_) @value ) @_.domain +;; name: +;;!! for (const aaa of bbb) {} +;;! ^^^ +;;! ---------------------- +;; value: +;;!! for (const aaa of bbb) {} +;;! ^^^ +;;! ---------------------- +(for_in_statement + left: (_) @name + right: (_) @value + ")" @_.domain.end.endOf +) @_.domain.start.startOf + [ (program) (formal_parameters) diff --git a/queries/python.scm b/queries/python.scm index 5673864cf3..180c675a59 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -140,6 +140,20 @@ (_) @value ) @_.domain +;; value: +;;!! for aaa in bbb: +;;! ^^^ +;;! --------------- +;; name: +;;!! for aaa in bbb: +;;! ^^^ +;;! --------------- +(for_statement + left: (_) @name + right: (_) @value + ":" @_.domain.end +) @_.domain.start.startOf + (comment) @comment @textFragment (string