Skip to content

Migrate remaining text based scope types to new scope handler setup #1052

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
9 tasks done
pokey opened this issue Oct 21, 2022 · 6 comments
Closed
9 tasks done

Migrate remaining text based scope types to new scope handler setup #1052

pokey opened this issue Oct 21, 2022 · 6 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@pokey
Copy link
Member

pokey commented Oct 21, 2022

We'd like to migrate all of our scope types to use the new scope handler setup introduced in #1031. See

  • existing scope handlers such as TokenScopeHandler,
  • the ScopeHandler interface definition, and
  • the NestedScopeHandler class, which might be of use

Scope types to migrate

@pokey pokey added bug Something isn't working enhancement New feature or request labels Oct 21, 2022
@pokey pokey added this to the Short list milestone Jul 6, 2023
@pokey pokey modified the milestones: Short list, 1.0 Jul 24, 2024
@AndreasArvidsson AndreasArvidsson changed the title Migrate remaining scope types to new scope handler setup Migrate remaining text based scope types to new scope handler setup Oct 22, 2024
@AndreasArvidsson
Copy link
Member

@phillco @pokey

I'm looking into migrating the notebook cell scope and just realize that we are actually using notebookCell in markdown.

(
(fenced_code_block
(fenced_code_block_delimiter) @_.interior.start.endOf
.
(block_continuation)
(fenced_code_block_delimiter) @_.interior.end.startOf
) @notebookCell
(#trim-end! @notebookCell)
(#insertion-delimiter! @notebookCell "\n\n")
)

The problem of course is that you can have markdown cells in a python notebook. What would "take next cell" do in a markdown cell?

@pokey
Copy link
Member Author

pokey commented Nov 21, 2024

I think that should just function like a nested scope, no? Haven't thought much about implementation but I think desired behaviour is well defined. Ie if you're in a code block in a markdown cell, then it targets next code block in the same cell if it exists, otherwise next cell. I believe that's how a nested scope would behave

@AndreasArvidsson
Copy link
Member

But what if you are not in a code block in markdown? Should next cell refer to a markdown code block further down or a next notebook cell?

Implementation wise I think it simplest to just ask the language scope provider and if we get no results go for a notebook cell. Does that sound good?

@pokey
Copy link
Member Author

pokey commented Nov 21, 2024

I think the consistent thing to do if we're treating it as nested scope would be to go to next markdown code block if we find one in current cell, otherwise next cell

Tho I do think that might be surprising, which kinda argues they should really be different scopes

@AndreasArvidsson
Copy link
Member

I think we will get that behavior if we do as I specified above.

But a different scope for notebook cells is of course another option. Maybe we should start with a combined one and see if anyone runs into problem?

@AndreasArvidsson AndreasArvidsson self-assigned this Nov 23, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 13, 2025
Fixes #1059

Related #1052

## 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

---------

Co-authored-by: Phil Cohen <[email protected]>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
cursorless-bot pushed a commit to hands-free-vim/cursorless.nvim that referenced this issue Jan 13, 2025
Fixes #1059

Related cursorless-dev/cursorless#1052

## 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

---------

Co-authored-by: Phil Cohen <[email protected]>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
@phillco
Copy link
Member

phillco commented Jan 19, 2025

All of these are done.

@phillco phillco closed this as completed Jan 19, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 19, 2025
Fixes #1053

Related #1052

I'm sure how we're gonna support the python comment style cells

```py
# %%
print("hello")
```

We have tests for them:
https://github.com/cursorless-dev/cursorless/blob/56ad4c5cef3f8c8267a098a375cf9139cbbfb0ff/data/fixtures/recorded/selectionTypes/pourCell.yml
But they are not a cell scope you can actually target. Tree sitter just
sees these as a comment and a function call. We could
1. Remove them. I'm probably leaning towards this.
2. Try to use regular expression to actually support them properly. That
means we're back to language specific implementations in typescript.
3. Do what we did before and just yield the current position as a
notebook target. Feels very hacky and not something I would like to do.

## Checklist

- [/] 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

---------

Co-authored-by: Phil Cohen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants