diff --git a/src/vs/workbench/contrib/files/browser/fileActions.ts b/src/vs/workbench/contrib/files/browser/fileActions.ts index cf5f62d2ad55763d9255c50d2416be5850620a24..f55a407d1e264aaec33eeb1d14da97a36dcaef20 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.ts @@ -743,11 +743,6 @@ export class CollapseExplorerView extends Action { const explorerView = explorerViewlet.getExplorerView(); if (explorerView) { explorerView.collapseAll(); - // If there is something being edited via input box make sure to close it #96198 - const editable = this.explorerService.getEditable(); - if (editable) { - await this.explorerService.setEditable(editable.stat, null); - } } } } diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index 415ed743c71f82f9bf0ef06ae817a3e2830bd400..59395768db78c2894bb65bae2f5ffa666fc660ad 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -311,19 +311,13 @@ export class ExplorerView extends ViewPane { } async setEditable(stat: ExplorerItem, isEditing: boolean): Promise { - let shouldRefresh = true; if (isEditing) { - if (stat.parent && stat.parent !== this.tree.getInput()) { - shouldRefresh = stat.parent.isDirectoryResolved; - await this.tree.expand(stat.parent); - } + await this.tree.expand(stat.parent!); } else { DOM.removeClass(this.treeContainer, 'highlight'); } - if (shouldRefresh) { - await this.refresh(false, stat.parent); - } + await this.refresh(false, stat.parent, false); if (isEditing) { DOM.addClass(this.treeContainer, 'highlight'); @@ -558,14 +552,14 @@ export class ExplorerView extends ViewPane { * Refresh the contents of the explorer to get up to date data from the disk about the file structure. * If the item is passed we refresh only that level of the tree, otherwise we do a full refresh. */ - refresh(recursive: boolean, item?: ExplorerItem): Promise { + refresh(recursive: boolean, item?: ExplorerItem, cancelEditing: boolean = true): Promise { if (!this.tree || !this.isBodyVisible() || (item && !this.tree.hasNode(item))) { // Tree node doesn't exist yet this.shouldRefresh = true; return Promise.resolve(undefined); } - if (this.explorerService.isEditable(undefined)) { + if (cancelEditing && this.explorerService.isEditable(undefined)) { this.tree.domFocus(); } @@ -709,6 +703,10 @@ export class ExplorerView extends ViewPane { } collapseAll(): void { + if (this.explorerService.isEditable(undefined)) { + this.tree.domFocus(); + } + const treeInput = this.tree.getInput(); if (Array.isArray(treeInput)) { if (hasExpandedRootChild(this.tree, treeInput)) { diff --git a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts index f2f985c8bef6c6745f476e7e0546afe62d4d0fd5..79836599b9e613f0383704e7d7706bd3714a00f2 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerViewer.ts @@ -445,15 +445,12 @@ export class FilesRenderer implements ICompressibleTreeRenderer { showInputBoxNotification(); }), + DOM.addDisposableListener(inputBox.inputElement, DOM.EventType.BLUR, () => { + done(inputBox.isInputValid(), true); + }), label, styler ]; - setTimeout(() => { - // Do not react immediatly on blur events due to tree refresh potentially causing an early blur #96566 - toDispose.push(DOM.addDisposableListener(inputBox.inputElement, DOM.EventType.BLUR, () => { - done(inputBox.isInputValid(), true); - })); - }, 100); return toDisposable(() => { done(false, false);