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

Allow context key expression that compares object properties #93825

Open
eamodio opened this issue Mar 31, 2020 · 4 comments
Open

Allow context key expression that compares object properties #93825

eamodio opened this issue Mar 31, 2020 · 4 comments
Labels
context-keys feature-request Request for new features or functionality
Milestone

Comments

@eamodio
Copy link
Contributor

eamodio commented Mar 31, 2020

@jrieken I was attempting to change the Timeline's timeline.excludeSources setting from an array to an object (as requested here).

I've pushed a branch with the changes here: eamodio/timeline-excludesources

Here I am trying to use the timeline.excludeSources.<source-id> property as the toggled condition.

toggled: ContextKeyExpr.notEquals(`config.timeline.excludeSources.${source.id}`, true)

This seems to work for the initial state, but it never gets updated when the property is removed or re-added. It looks like the cause is somewhere in here:

this._listener = this._configurationService.onDidChangeConfiguration(event => {
if (event.source === ConfigurationTarget.DEFAULT) {
// new setting, reset everything
const allKeys = keys(this._values);
this._values.clear();
emitter.fire(new ArrayContextKeyChangeEvent(allKeys));
} else {
const changedKeys: string[] = [];
for (const configKey of event.affectedKeys) {
const contextKey = `config.${configKey}`;
if (this._values.has(contextKey)) {
this._values.delete(contextKey);
changedKeys.push(contextKey);
}
}
emitter.fire(new ArrayContextKeyChangeEvent(changedKeys));
}
});
}

Where this._values will contain timeline.excludeSources.<source-id>, but the event.affectedKeys will only have timeline.excludeSources.

/cc @rebornix

@jrieken
Copy link
Member

jrieken commented Mar 31, 2020

but the event.affectedKeys will only have timeline.excludeSources.

That sound like an issue with the event itself, or how should this work?

@sandy081
Copy link
Member

event.affectedKeys only contain the real configuration keys but not the full nested value tree.

@sandy081 sandy081 removed their assignment Mar 31, 2020
@jrieken
Copy link
Member

jrieken commented Mar 31, 2020

@eamodio this looks like a case for different printing/comparing logic. We cannot traverse into objects that have changed because this happens a lot but we can think of either a new context key operator that compare object-property values or use the regexp-operator with some JSON-based value printing (which is hopefully not huge strings...)

@eamodio
Copy link
Contributor Author

eamodio commented Mar 31, 2020

Yeah, OK. I will leave the timeline.excludeSources as an array, but will look into adding a new context expression for object props. Thanks!

@jrieken jrieken added context-keys feature-request Request for new features or functionality labels Apr 1, 2020
@jrieken jrieken changed the title "config." context keys for an object property won't correctly cause menus to update Allow context key expression that compares object properties Apr 1, 2020
@vscodebot vscodebot bot added this to the Backlog Candidates milestone Apr 1, 2020
@jrieken jrieken modified the milestones: Backlog Candidates, Backlog Apr 1, 2020
@microsoft microsoft deleted a comment from vscodebot bot Apr 1, 2020
@jrieken jrieken removed their assignment Oct 22, 2020
@lramos15 lramos15 assigned JacksonKearl and unassigned eamodio Oct 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context-keys feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants