Skip to content

Commit b97f314

Browse files
Added scope type for "inside" (#2776)
Inside/interior today is a modifier and will stay so in the future, but we are also introducing interior as a scope type. This will allow us to do `"take inside"` when on a if statement, python function and so on. It now takes the closest of the nearest tree-sitter interior _or_ surrounding pair. This is most useful for Python; in other languages with {} statement-blocks, the braces would already be easy to target, but now "take inside" behaves intuitively there as well. The scm syntax `@scope.interior` have been replaced by `@interior` as its own scope type. Fixes #1046 ## 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 ## Release notes You can now use "inside" to refer to the inside body of a language scope (function, if statement, etc). This is especially useful for Python, because previously you had to think about what scope you were targeting -- "take inside" now just works. It also works nicely for targeting the inside of C-style statements that don't have `{}` braces, like single line conditionals or loops. In Python, this also means that you can now target the inside of the function ("take inside") even while the cursor is in a related location (such as in its name). Note that this behavior currently only exists for Python; we plan to port it to other languages as well since it is useful. --------- Co-authored-by: Phil Cohen <[email protected]>
1 parent 1d7c9bd commit b97f314

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/spoken_forms.py

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def handle_new_values(csv_name: str, values: list[SpokenFormEntry]):
161161
"textFragment",
162162
"disqualifyDelimiter",
163163
"pairDelimiter",
164+
"interior",
164165
],
165166
default_list_name="scope_type",
166167
),

0 commit comments

Comments
 (0)