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

Implement conditional bindings #14

Merged
merged 27 commits into from
Sep 2, 2020
Merged

Implement conditional bindings #14

merged 27 commits into from
Sep 2, 2020

Conversation

stevenguh
Copy link
Member

Close #11

@marcoieni It would be nice if you can look at the README and see if conditional binding makes sense to you.

@stevenguh
Copy link
Member Author

@marcoieni Is there any update on this? I would like to merge it and unblock the task on the VSpaceCode repo to implement <spc> f t and major mode.

@marcoieni
Copy link
Member

I procrastinated a little bird here, sorry, I was planning to do it in the next hours :)

@marcoieni
Copy link
Member

I tried to improve a little bit the README, but in my opinion the syntax is a little bit too complicated to be easily understand.

I am sure you had valid reasons for your design choices, but in the following I will write down some things that seemed strange to me the first time I read them:

key and serialization

  • It is confusing that the key contains conditions, too. I would expect that the key is just a character.
  • In order to explain what languageId:javascript;when:sideBarVisible means, you first showed a json. Why don't we just use the json instead?

examples

this:

{
  "key": "when:sideBarVisible && explorerViewletVisible",
  "name": "Hide explorer",
  "type": "command",
  "command": "workbench.action.toggleSidebarVisibility"
}

might become this:

{
    "condition": {
        "when": "sideBarVisible && explorerViewletVisible"
    },
    "name": "Hide explorer",
    "type": "command",
    "command": "workbench.action.toggleSidebarVisibility"
}

and this:

{
    "key": "languageId:javascript;when:sideBarVisible",
    "name": "Open file",
    "type": "command",
    "command": "workbench.action.files.openFileFolder"
},

might become this:

{
  "condition": {
      "languageId": "javascript",
      "when": "sideBarVisible"
   },
  "name": "Open file",
  "type": "command",
  "command": "workbench.action.files.openFileFolder"
},

Other stuff, WIP

@stevenguh
Copy link
Member Author

That's why I marked this as experimental for now, and change it if we need to. I don't like the reusing of the key key either; however, it's more consistent and flexible with the overrides and other types than to accept a condition json in an overrides keys. The thinking is I would rather have it be weird consistently (using keys for both binding and overrides, instead of condition in binding, and keys in overrides) Also, it doesn't increase the complexity of json schema. It's definitely a trade-off sadly :(


I explained the serialization because the same serialization is used for both keys in overrides and key in binding item. I am a little worried that putting the condition in the example will be more confusing? If you think that's clearer, do you mind updating the README? :) We can always change the doc if people find it confusing

@marcoieni
Copy link
Member

It's definitely a trade-off sadly :(

Ok, so we keep key instead of condition.

I explained the serialization because the same serialization is used for both keys in overrides and key in binding item.

If we keep this syntax is ok to explain it of course.

I am a little worried that putting the condition in the example will be more confusing?

We decided to keep key instead of condition, so we should not put condition in the README, right?

Overall, since we decided to not change the implementation at the moment, I think that the README is ok as it is (except one comment I will do in the code in a couple of minutes).

@stevenguh
Copy link
Member Author

so we should not put condition in the README, right?

If that's clearer :)

Thank you for reading the issue and working with me :)

README.md Outdated
}
```

You can then define the follow bindings that uses that specific `key` and `when`.
Copy link
Member

Choose a reason for hiding this comment

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

This and the following json are not very clear to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated, let me know the updated version is clearer :)

@marcoieni
Copy link
Member

If that's clearer :)

If condition is not a valid keyword, I don't think we should put it in the README.

Thank you for reading the issue and working with me :)

no problem, thank you for working on this, it will enable really great stuff :)

@stevenguh
Copy link
Member Author

I will fix them later today, and we can look at them again tomorrow :) I know it's probably late in your time zone.

@marcoieni
Copy link
Member

Ok, with your changes it was a lot clearer, thanks!
I reviewed it a bit. Of course feel free to revert/change as you like.

I also hidden the section by default, since it is very long and experimental. In this way users are not forced to read it.

@stevenguh
Copy link
Member Author

Thank you for working on it. Can't wait to the features on VSpaceCode that can build on top of it🚢 ship it.

@stevenguh stevenguh merged commit 685fac2 into develop Sep 2, 2020
@stevenguh stevenguh deleted the conditionals branch September 2, 2020 18:55
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