Fixes microsoft/monaco-editor#2081: Dispatch Escape via keybinding service in tree

This commit is contained in:
Alex Dima 2020-09-18 15:08:23 +02:00
parent 0aba673183
commit 30671276a3
No known key found for this signature in database
GPG key ID: 6E58D7B045760DA0

View file

@ -33,6 +33,8 @@ import { FileReferences, OneReference, ReferencesModel } from '../referencesMode
import { FuzzyScore } from 'vs/base/common/filters';
import { SplitView, Sizing } from 'vs/base/browser/ui/splitview/splitview';
import { IUndoRedoService } from 'vs/platform/undoRedo/common/undoRedo';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeyCode } from 'vs/base/common/keyCodes';
class DecorationsManager implements IDisposable {
@ -219,6 +221,7 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
@peekView.IPeekViewService private readonly _peekViewService: peekView.IPeekViewService,
@ILabelService private readonly _uriLabel: ILabelService,
@IUndoRedoService private readonly _undoRedoService: IUndoRedoService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
) {
super(editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true }, _instantiationService);
@ -322,6 +325,15 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
listBackground: peekView.peekViewResultsBackground
}
};
if (this._defaultTreeKeyboardSupport) {
// the tree will consume `Escape` and prevent the widget from closing
this._callOnDispose.add(dom.addStandardDisposableListener(this._treeContainer, 'keydown', (e) => {
if (e.equals(KeyCode.Escape)) {
this._keybindingService.dispatchEvent(e, e.target);
e.stopPropagation();
}
}, true));
}
this._tree = this._instantiationService.createInstance(
ReferencesTree,
'ReferencesWidget',