Skip to content

Fix python surrounding pairs in new tree-sitter-python version #328

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

Closed
pokey opened this issue Nov 23, 2021 · 2 comments
Closed

Fix python surrounding pairs in new tree-sitter-python version #328

pokey opened this issue Nov 23, 2021 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@pokey
Copy link
Member

pokey commented Nov 23, 2021

In newer versions of tree-sitter-python, it uses string_start and string_end as the type for string delimiter tokens. This will break all of our surrounding pairs in python.

We should fix this by actually looking at the token text to rather than just its type. We to be a bit careful though because for some cases we actually do prefer to use the type, for example with a format string or triple quote. We probably want to match the type, and then have a mapping from text to what kind of pair it is, eg f""" should map to doubleQuotes, etc. Note that this will require us to take into account language id when determining surrounding pair

We should probably solve this one after #1061

In addition, it uses string_content as the type for the content of the string, which appears to be different from today.

@pokey pokey added the bug Something isn't working label Nov 23, 2021
@pokey pokey mentioned this issue Nov 23, 2021
30 tasks
@pokey pokey added this to the On deck milestone Jan 30, 2022
@pokey pokey changed the title Fix python twin surrounding scope type Fix python surrounding pairs in new tree-sitter-python version Jul 7, 2023
@pokey pokey changed the title Fix python surrounding pairs in new tree-sitter-python version Fix python surrounding pairs in new tree-sitter-python version Jul 7, 2023
@AndreasArvidsson AndreasArvidsson removed their assignment Jul 22, 2023
@pokey
Copy link
Member Author

pokey commented Jun 14, 2024

Note that this was partially fixed in #2409, but we still don't yet actually look at the text of the delimiters, just their type, which is always string_start / string_end, so we don't properly distinguish between single and double quotes. Ie if you say "take twin" inside double quotes, it will select them.

See also #1812 (comment)

@AndreasArvidsson
Copy link
Member

This is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants