diff --git a/packages/common/src/scopeSupportFacets/python.ts b/packages/common/src/scopeSupportFacets/python.ts index 1e1b4fd791..b9c666ffa6 100644 --- a/packages/common/src/scopeSupportFacets/python.ts +++ b/packages/common/src/scopeSupportFacets/python.ts @@ -12,6 +12,7 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = { "name.resource": supported, "name.resource.iteration": supported, "value.foreach": supported, + "value.yield": supported, "value.resource": supported, "value.resource.iteration": supported, diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts index d47086df2c..e5781be5a6 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts @@ -299,6 +299,10 @@ export const scopeSupportFacetInfos: Record< description: "Value (RHS) of a field in a class / interface", scopeType: "value", }, + "value.yield": { + description: "Value of a yield statement", + scopeType: "value", + }, "value.resource": { description: "Value of a 'with' / 'use' / 'using' statement", scopeType: "value", diff --git a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts index 3adfe5c1ca..cde875d921 100644 --- a/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts +++ b/packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts @@ -78,6 +78,7 @@ const scopeSupportFacets = [ "value.return", "value.return.lambda", "value.field", + "value.yield", "value.resource", "value.resource.iteration", diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.yield.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.yield.scope new file mode 100644 index 0000000000..1935369c84 --- /dev/null +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.yield.scope @@ -0,0 +1,21 @@ +def aaa(): + yield bbb +--- + +[Content] = 1:10-1:13 +1| yield bbb + >---< + +[Removal] = 1:9-1:13 +1| yield bbb + >----< + +[Leading delimiter] = 1:9-1:10 +1| yield bbb + >-< + +[Domain] = 1:4-1:13 +1| yield bbb + >---------< + +[Insertion delimiter] = " " diff --git a/queries/python.scm b/queries/python.scm index 1f465abea9..074d497295 100644 --- a/queries/python.scm +++ b/queries/python.scm @@ -142,6 +142,18 @@ (_) @value ) @_.domain +;;!! yield 1 +;;! ^ +;;! xx +;;! ------- +;; +;; NOTE: in tree-sitter, both "yield" and the "1" are children of `yield` but +;; "yield" is anonymous whereas "1" is named node, so no need to exclude +;; explicitly +(yield + (_) @value +) @_.domain + ;;!! with aaa: ;;! ^^^ ;;! --------