Skip to content
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

ifEmpty does not pass count to it's subcommands. #310

Closed
haberdashPI opened this issue Aug 23, 2023 · 1 comment
Closed

ifEmpty does not pass count to it's subcommands. #310

haberdashPI opened this issue Aug 23, 2023 · 1 comment
Labels
question Further information is requested

Comments

@haberdashPI
Copy link

While debugging #308 I discovered that for all cases I tried, the count entered by a user is not passed on to the subcommands called in "then" or "otherwise" of an "ifEmpty" command.

I'm happy to try to resolve this but I am having a but of trouble following the data flow for how counts get passed around. Looking at the source for buildCommands it appears that the count is only passed down to individual commands if it is an explicit argument. Is this just so one can specify a command with an explicit numerical argument, or is there some way to spell out, in a call to ifEmpty that you want the count to be passed to one of the subcommands. If so, how does one do that, and is that documented somewhere? (I can't seem to find it).

@71
Copy link
Owner

71 commented Sep 27, 2023

This probably needs some better documentation, but you can use the $include and $exclude arguments for that:

  {
    "key": ",",
    "command": "dance.ifEmpty",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "then": [["dance.select.down.extend", { "$include": ["count"] }]],
      "otherwise": [["dance.select.up.extend", { "$include": ["count"] }]],
    },
  },

or:

  {
    "key": ",",
    "command": "dance.ifEmpty",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "then": [["dance.select.down.extend", { "$exclude": [] }]],
      "otherwise": [["dance.select.up.extend", { "$exclude": [] }]],
    },
  },

Note regarding your PR: when you write ... in the arguments of a command (example), this is expanded to "$exclude": [], i.e. other arguments are passed to the command.

@71 71 closed this as completed Sep 27, 2023
@71 71 added the question Further information is requested label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants