-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support when
-like condition
#11
Comments
Just jotting here. We will likely need another context variable like |
could this enable major mode? |
Can you elaborate a little bit more? I am not familiar with major mode. |
In spacemacs you have major-modes, like "python", "markdown", and so on. So for example if you open a When you are using a mode, key bindings under This means that when you are editing a markdown, |
Thank you for the clear explanation. I think this work should take this into account and facilitate major mode as well if we are implementing a type called "conditional". |
Just jotting here again. We probably can use For the conditional command: {
"key": "t",
"name": "Show tree/explorer view",
"type": "conditional",
"commands": ["workbench.view.explorer", "workbench.action.toggleSidebarVisibility"],
"conditional": {"when": [null, "sideBarVisible && explorerViewletVisible"]}
} For conditional binding like major mode: {
"key": "m",
"name": "Major mode",
"type": "conditional",
"bindings": [[...], [...]],
"conditional": {"langId": [null, "javascript"]}
} These are not finalized yet, just a thought |
On second thought that would make the json schema wayyyyy too complicated. The following example could be better in terms of flexibility and consistent style format with the current config. The format of the conditions here changed from specifying one type of conditions to a simple array that do simple waterfall style conditions of any types of conditions (either when or langId) to provide flexibility and consistent format style For the conditional command: {
"key": "t",
"name": "Show tree/explorer view",
"type": "conditional",
"conditional": [
{
"type": "command",
"command": "workbench.view.explorer"
},
{
"type": "command",
"command": "workbench.action.toggleSidebarVisibility"
}
],
"conditions": [null, {"when": "sideBarVisible && explorerViewletVisible"}]
} For conditional binding like major mode: {
"key": "m",
"name": "Major mode",
"type": "conditional",
"conditional": [
{
"type": "bindings",
"bindings": [...],
},
{
"type": "bindings",
"bindings": [...],
}
],
"conditions": [null, {"langId": "javascript"}]
} |
Why the null in conditions? |
The null is used like the else in a if statement. Not sure if there's a better way to handle that. |
Oh, ok, so the first condition is referred to the first conditional and so on. It is a little bit confusing. Imaging when you have a lot of conditions.. Keeping track of positions might be difficult. What if you insert the condition inside each conditional? For example
If no condition is present it is considered default (null) |
Oh I like this where all the information is in the object itself instead of two places |
I have a working prototype on If a user wants to redefined the condition, the user can use the following example to override the whole conditional binding. {
"bindingOverrides": [
{
"keys": "m",
"name": "Major",
"conditional": [
{
"type": "bindings",
"bindings": []
},
{
"type": "bindings",
"name": "JavaScript",
"bindings": [],
"condition": {
"langId": "javascript"
}
}
]
}
]
} In order to implement the traversal of the conditional bindings, I have to re-use the keys in the current overrides format in the following example. "bindingOverrides": [
{
"keys": ["m", "languageId=typescript"],
"name": "123",
"type": "command",
"command": "workbench.action.editor.changeLanguageMode"
}
] Although, this works for the most part, There are two things that bug me with the current implementation.
{
"key": "m",
"name": "Major mode",
"type": "conditional",
"bindings": [
{
"key": "",
"type": "bindings",
"bindings": [...],
},
{
"key": "langId=javascript"
"type": "bindings",
"bindings": [...],
}
],
}
"bindingOverrides": [
{
"keys": [
"m",
"when=sideBarVisible%20%26%26%20explorerViewletVisible"
],
"name": "123",
"type": "command",
"command": "workbench.action.editor.changeLanguageMode"
}
] I am thinking
EDIT: |
Just implemented a custom query string, that cleaned up both the code and the config a bit :) |
Released |
Split from #5.
My current thinking on this is at #5 (comment)
The text was updated successfully, but these errors were encountered: