Skip to content

Add support for 'all' modifier for items within a collection #597

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

Conversation

Will-Sommers
Copy link
Collaborator

@Will-Sommers Will-Sommers commented Mar 9, 2022

What

This PR addresses Issue 473 and adds support for the "all" modifier within a list.

I'm pretty rusty on the .ts types side and also might be missing some context about casting Range as Selection and setting it. I think there is likely a more elegant way.

Checklist

  • I have added tests
  • Update cheatsheet/docs

@Will-Sommers Will-Sommers requested a review from pokey as a code owner March 9, 2022 21:42
@Will-Sommers
Copy link
Collaborator Author

Will-Sommers commented Mar 9, 2022

Fixing/Running tests locally, still needing to close VSCode.

Edit:
Running the most recent commit, passing on GH, is failing for me locally as well. Not a huge deal but I noticed it failing in a similar way on another branch. I'll make another issue but it looks like indentation is off for some(~24) tests, mostly around `"(if | state) wrap this" and another indentation one. Mostly in Python but also Java and TypeScript.

Here's an example:

  22) recorded test cases
       /Users/.../recorded/languages/typescript/ifElseWrapThis:

      AssertionError [ERR_ASSERTION]: Unexpected final state
      + expected - actual

       {
      -  "documentContents": "if () {\n  const foo = \"hello\";\n} else {\n  \n}"
      +  "documentContents": "if () {\n    const foo = \"hello\";\n} else {\n    \n}"
         "selections": [
           {
             "active": {
               "character": 4

"type": "containingScope",
"scopeType": m.cursorless_scope_type,
"includeSiblings": m[0] == "every",
"""Expand to every scope"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely open to putting this into another file, my python is a little weak as is my understanding of how it interacts with Talon. Just lmk.


@mod.capture(rule="[every] {user.cursorless_scope_type}")
@mod.capture(rule="[(every|all)] {user.cursorless_scope_type}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nifty if we could put this into a capture against the set above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use a Talon list, no?

"modifier": {
"type": "everyScope",
"scopeType": m.cursorless_scope_type,
"contiguousRange": m[0] == "all",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: re-add check on for items here

@Will-Sommers
Copy link
Collaborator Author

Will-Sommers commented Apr 18, 2022

Looking at the test failures. A few notes to myself:

  • Re-running the tests via the GH UI resulted in Error: Cannot activate the 'Cursorless' extension because it depends on unknown extension 'pokey.parse-tree'
  • Tests are failing initially because this PR changes change the type from containingScope to everyScope

Trying to get the test transfomer running as well, will need to take a look later.

Copy link
Member

@pokey pokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this one's going to need some conflict resolution / tweaking to account for changes introduced in #672. I also appear to have some pending comments; not sure how relevant they still har

Comment on lines +49 to +51
mod.list("select_multiple_modifiers", desc="modifiers for multiple selections")
multiple_modifiers = {"every", "all"}
ctx.lists["user.select_multiple_modifiers"] = multiple_modifiers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that these terms should be csv-configurable

"modifier": {
"type": "everyScope",
"scopeType": m.cursorless_scope_type,
"contiguousRange": m[0] == "all" and m[1] == "collectionItem",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we only support this one for collectionItem?

@pokey
Copy link
Member

pokey commented Aug 17, 2022

I'm going to close this one for now, because:

  • for "chuck", we can just use "chuck every"
  • For other use cases, I think I'd lean towards implementing this one using Add "range" modifier #524
  • This PR has lots of merge conflicts and seems like it will be painful to take to the finish line

Feel free to re-open if you wanna take a crack at it

@pokey pokey closed this Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants