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

fix: when context key cause different menu bars change at same time. only one menu bar refreshed #4182

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/core-browser/src/menu/next/menubar-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,23 @@ export class MenubarServiceImpl extends Disposable implements AbstractMenubarSer
// 监听 menubar 刷新事件
this.addDispose(Event.debounce(this.menuRegistry.onDidChangeMenubar, () => {}, 50)(this._build, this));

const menuIds = new Set<string>();
// 监听内部的 onMenuChange 刷新单个 menubarItem 下的所有节点
this.addDispose(
Event.debounce(this.onMenuChange, (l, menuId: string) => menuId, 50)(this._rebuildSingleRootMenus, this),
Event.debounce(
this.onMenuChange,
(l, menuId: string) => {
menuIds.add(menuId);
return menuId;
},
50,
)(() => {
const changedMenuIds = [...menuIds.values()];
menuIds.clear();
changedMenuIds.forEach((menuId) => {
this._rebuildSingleRootMenus(menuId);
});
}, this),
);

this.addDispose(this._onDidMenuBarChange);
Expand Down
Loading