Skip to content

Commit

Permalink
different fix for microsoft#59733
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Oct 2, 2018
1 parent eafa0ad commit d848101
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
22 changes: 1 addition & 21 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IConstructorSignature2, createDecorator } from 'vs/platform/instantiati
import { IKeybindings } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Event } from 'vs/base/common/event';
import { URI, UriComponents } from 'vs/base/common/uri';

Expand Down Expand Up @@ -237,7 +237,6 @@ export class MenuItemAction extends ExecuteCommandAction {
readonly alt: MenuItemAction;

private _options: IMenuActionOptions;
private _contextListener: IDisposable;

constructor(
item: ICommandAction,
Expand All @@ -253,19 +252,6 @@ export class MenuItemAction extends ExecuteCommandAction {

this.item = item;
this.alt = alt ? new MenuItemAction(alt, undefined, this._options, contextKeyService, commandService) : undefined;

if (item.precondition) {
const preconditionKeysSet = new Set<string>();
for (let key of item.precondition.keys()) {
preconditionKeysSet.add(key);
}

this._contextListener = contextKeyService.onDidChangeContext(event => {
if (event.affectsSome(preconditionKeysSet)) {
this._setEnabled(contextKeyService.contextMatchesRules(item.precondition));
}
});
}
}

run(...args: any[]): TPromise<any> {
Expand All @@ -281,12 +267,6 @@ export class MenuItemAction extends ExecuteCommandAction {

return super.run(...runArgs);
}

dispose(): void {
this._contextListener = dispose(this._contextListener);

super.dispose();
}
}

export class SyncActionDescriptor {
Expand Down
5 changes: 5 additions & 0 deletions src/vs/platform/actions/common/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ export class Menu implements IMenu {

// keep keys for eventing
Menu._fillInKbExprKeys(item.when, keysFilter);

// keep precondition keys for event if applicable
if (isIMenuItem(item) && item.command.precondition) {
Menu._fillInKbExprKeys(item.command.precondition, keysFilter);
}
}

// subscribe to context changes
Expand Down

0 comments on commit d848101

Please sign in to comment.