Skip to content

Commit 781fb48

Browse files
authored
disable EditorContent-menu for embedded editors, ignore the FloatingClickMenu-contribution for notebook code edtors (microsoft#162186)
fixes microsoft#160910
1 parent d31d71d commit 781fb48

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

src/vs/workbench/browser/codeeditor.ts

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { IMenuService, MenuId } from 'vs/platform/actions/common/actions';
2626
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
2727
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
2828
import { IAction } from 'vs/base/common/actions';
29+
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
2930

3031
export interface IRangeHighlightDecoration {
3132
resource: URI;
@@ -224,28 +225,31 @@ export class FloatingClickMenu extends Disposable implements IEditorContribution
224225
) {
225226
super();
226227

227-
const menu = menuService.createMenu(MenuId.EditorContent, contextKeyService);
228-
const menuDisposables = new DisposableStore();
229-
const renderMenuAsFloatingClickBtn = () => {
230-
menuDisposables.clear();
231-
if (!editor.hasModel() || editor.getOption(EditorOption.inDiffEditor)) {
232-
return;
233-
}
234-
const actions: IAction[] = [];
235-
createAndFillInActionBarActions(menu, { renderShortTitle: true, shouldForwardArgs: true }, actions);
236-
if (actions.length === 0) {
237-
return;
238-
}
239-
// todo@jrieken find a way to handle N actions, like showing a context menu
240-
const [first] = actions;
241-
const widget = instantiationService.createInstance(FloatingClickWidget, editor, first.label, first.id);
242-
menuDisposables.add(widget);
243-
menuDisposables.add(widget.onClick(() => first.run(editor.getModel().uri)));
244-
widget.render();
245-
};
246-
this._store.add(menu);
247-
this._store.add(menuDisposables);
248-
this._store.add(menu.onDidChange(renderMenuAsFloatingClickBtn));
249-
renderMenuAsFloatingClickBtn();
228+
// DISABLED for embedded editors. In the future we can use a different MenuId for embedded editors
229+
if (!(editor instanceof EmbeddedCodeEditorWidget)) {
230+
const menu = menuService.createMenu(MenuId.EditorContent, contextKeyService);
231+
const menuDisposables = new DisposableStore();
232+
const renderMenuAsFloatingClickBtn = () => {
233+
menuDisposables.clear();
234+
if (!editor.hasModel() || editor.getOption(EditorOption.inDiffEditor)) {
235+
return;
236+
}
237+
const actions: IAction[] = [];
238+
createAndFillInActionBarActions(menu, { renderShortTitle: true, shouldForwardArgs: true }, actions);
239+
if (actions.length === 0) {
240+
return;
241+
}
242+
// todo@jrieken find a way to handle N actions, like showing a context menu
243+
const [first] = actions;
244+
const widget = instantiationService.createInstance(FloatingClickWidget, editor, first.label, first.id);
245+
menuDisposables.add(widget);
246+
menuDisposables.add(widget.onClick(() => first.run(editor.getModel().uri)));
247+
widget.render();
248+
};
249+
this._store.add(menu);
250+
this._store.add(menuDisposables);
251+
this._store.add(menu.onDidChange(renderMenuAsFloatingClickBtn));
252+
renderMenuAsFloatingClickBtn();
253+
}
250254
}
251255
}

src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,13 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
8686
import { NotebookPerfMarks } from 'vs/workbench/contrib/notebook/common/notebookPerformance';
8787
import { BaseCellEditorOptions } from 'vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions';
8888
import { ILogService } from 'vs/platform/log/common/log';
89+
import { FloatingClickMenu } from 'vs/workbench/browser/codeeditor';
8990

9091
const $ = DOM.$;
9192

9293
export function getDefaultNotebookCreationOptions(): INotebookEditorCreationOptions {
9394
// We inlined the id to avoid loading comment contrib in tests
94-
const skipContributions = ['editor.contrib.review'];
95+
const skipContributions = ['editor.contrib.review', FloatingClickMenu.ID];
9596
const contributions = EditorExtensionsRegistry.getEditorContributions().filter(c => skipContributions.indexOf(c.id) === -1);
9697

9798
return {

0 commit comments

Comments
 (0)