ref: #199744 , because command with the same name cannot be registered now. The process of switching menu bars is accompanied by the destruction and initialization of two custom menu bars from A and B respectively, and their destruction execution order cannot be guaranteed. When one of the instances is destroyed and executed, the initialization of the new instance will have this problem, because initialization means registering a command with the same name. vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.ts Line 440 in f7f9fb0 | | id: workbench.actions.menubar.focus, |
4条答案
按热度按时间jdzmm42g1#
ref: #199744 , because command with the same name cannot be registered now.
The process of switching menu bars is accompanied by the destruction and initialization of two custom menu bars from A and B respectively, and their destruction execution order cannot be guaranteed. When one of the instances is destroyed and executed, the initialization of the new instance will have this problem, because initialization means registering a command with the same name.
vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.ts
Line 440 in f7f9fb0
| | id:
workbench.actions.menubar.focus
, |tquggr8v2#
我认为这里的问题是菜单栏控件在一个地方被销毁,然后在另一个地方被创建(标题栏、活动栏),但顺序不能保证先销毁后创建,因此这个操作会被第二次注册,然后被销毁:
vscode/src/vs/workbench/browser/parts/titlebar/menubarControl.ts
第437行到第454行
| | this._register(registerAction2(classextendsAction2{ |
| | constructor(){ |
| | super({ |
| | id:
workbench.actions.menubar.focus
, || | title: localize2('focusMenu','Focus Application Menu'), |
| | keybinding: { |
| | primary: KeyMod.Alt|KeyCode.F10, |
| | weight: KeybindingWeight.WorkbenchContrib, |
| | when: IsWebContext |
| | }, |
| | f1: true |
| | }); |
| | } |
| | |
| | asyncrun(): Promise{ |
| | that.menubar?.toggleFocus(); |
| | } |
| | })); |
我们最近才改成在这个情况下抛出错误,现在这会破坏这个流程,但这个问题之前就已经存在了...
5cnsuln73#
id:
workbench.actions.menubar.focus
,是的,我也找到了。我最初的想法是通过某种事件机制(如使用
this.titleService.onMenubarVisibilityChange
)确保在卸载完成后重新安装是合理的,但这需要监听两边。vuv7lop34#
我们最近才改成抛出错误,现在破坏了这个流程,但问题之前就已经存在了。
是的,以前同名的命令可以被覆盖而不会引起问题。现在抛出的异常导致处理程序不被执行,开关失败。