Skip to content

Commit ba4aa7a

Browse files
committed
1 parent 5c112d7 commit ba4aa7a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ import { Command } from 'vs/editor/common/modes';
7979
import { renderCodicons } from 'vs/base/common/codicons';
8080
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
8181
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
82+
import { domEvent } from 'vs/base/browser/event';
83+
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
8284

8385
type TreeElement = ISCMRepository | ISCMInput | ISCMResourceGroup | IResourceNode<ISCMResource, ISCMResourceGroup> | ISCMResource;
8486

@@ -272,17 +274,24 @@ class InputRenderer implements ICompressibleTreeRenderer<ISCMInput, FuzzyScore,
272274
constructor(
273275
private outerLayout: ISCMLayout,
274276
private updateHeight: (input: ISCMInput, height: number) => void,
277+
private focusTree: () => void,
275278
@IInstantiationService private instantiationService: IInstantiationService,
276279
) { }
277280

278281
renderTemplate(container: HTMLElement): InputTemplate {
279282
// hack
280283
addClass(container.parentElement!.parentElement!.querySelector('.monaco-tl-twistie')! as HTMLElement, 'force-no-twistie');
281284

285+
const disposables = new DisposableStore();
282286
const inputElement = append(container, $('.scm-input'));
283287
const inputWidget = this.instantiationService.createInstance(SCMInputWidget, inputElement);
288+
disposables.add(inputWidget);
289+
290+
const onKeyDown = Event.map(domEvent(container, 'keydown'), e => new StandardKeyboardEvent(e));
291+
const onEscape = Event.filter(onKeyDown, e => e.keyCode === KeyCode.Escape);
292+
disposables.add(onEscape(this.focusTree));
284293

285-
return { inputWidget, disposable: Disposable.None, templateDisposable: inputWidget };
294+
return { inputWidget, disposable: Disposable.None, templateDisposable: disposables };
286295
}
287296

288297
renderElement(node: ITreeNode<ISCMInput, FuzzyScore>, index: number, templateData: InputTemplate): void {
@@ -1541,7 +1550,7 @@ export class SCMViewPane extends ViewPane {
15411550

15421551
this._register(repositories.onDidSplice(() => this.updateActions()));
15431552

1544-
this.inputRenderer = this.instantiationService.createInstance(InputRenderer, this.layoutCache, (input, height) => this.tree.updateElementHeight(input, height));
1553+
this.inputRenderer = this.instantiationService.createInstance(InputRenderer, this.layoutCache, (input, height) => this.tree.updateElementHeight(input, height), () => this.tree.domFocus());
15451554
const delegate = new ProviderListDelegate(this.inputRenderer);
15461555

15471556
const actionViewItemProvider = (action: IAction) => this.getActionViewItem(action);

0 commit comments

Comments
 (0)