未验证 提交 bddccf85 编写于 作者: I Isidor Nikolic 提交者: GitHub

Merge pull request #96853 from jeanp413/fix-96846

Fix empty item in explorer after clicking on Collapse Folders action while editing new file/folder
...@@ -743,11 +743,6 @@ export class CollapseExplorerView extends Action { ...@@ -743,11 +743,6 @@ export class CollapseExplorerView extends Action {
const explorerView = explorerViewlet.getExplorerView(); const explorerView = explorerViewlet.getExplorerView();
if (explorerView) { if (explorerView) {
explorerView.collapseAll(); 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);
}
} }
} }
} }
......
...@@ -311,19 +311,13 @@ export class ExplorerView extends ViewPane { ...@@ -311,19 +311,13 @@ export class ExplorerView extends ViewPane {
} }
async setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void> { async setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void> {
let shouldRefresh = true;
if (isEditing) { if (isEditing) {
if (stat.parent && stat.parent !== this.tree.getInput()) { await this.tree.expand(stat.parent!);
shouldRefresh = stat.parent.isDirectoryResolved;
await this.tree.expand(stat.parent);
}
} else { } else {
DOM.removeClass(this.treeContainer, 'highlight'); DOM.removeClass(this.treeContainer, 'highlight');
} }
if (shouldRefresh) { await this.refresh(false, stat.parent, false);
await this.refresh(false, stat.parent);
}
if (isEditing) { if (isEditing) {
DOM.addClass(this.treeContainer, 'highlight'); DOM.addClass(this.treeContainer, 'highlight');
...@@ -558,14 +552,14 @@ export class ExplorerView extends ViewPane { ...@@ -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. * 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. * 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<void> { refresh(recursive: boolean, item?: ExplorerItem, cancelEditing: boolean = true): Promise<void> {
if (!this.tree || !this.isBodyVisible() || (item && !this.tree.hasNode(item))) { if (!this.tree || !this.isBodyVisible() || (item && !this.tree.hasNode(item))) {
// Tree node doesn't exist yet // Tree node doesn't exist yet
this.shouldRefresh = true; this.shouldRefresh = true;
return Promise.resolve(undefined); return Promise.resolve(undefined);
} }
if (this.explorerService.isEditable(undefined)) { if (cancelEditing && this.explorerService.isEditable(undefined)) {
this.tree.domFocus(); this.tree.domFocus();
} }
...@@ -709,6 +703,10 @@ export class ExplorerView extends ViewPane { ...@@ -709,6 +703,10 @@ export class ExplorerView extends ViewPane {
} }
collapseAll(): void { collapseAll(): void {
if (this.explorerService.isEditable(undefined)) {
this.tree.domFocus();
}
const treeInput = this.tree.getInput(); const treeInput = this.tree.getInput();
if (Array.isArray(treeInput)) { if (Array.isArray(treeInput)) {
if (hasExpandedRootChild(this.tree, treeInput)) { if (hasExpandedRootChild(this.tree, treeInput)) {
......
...@@ -445,15 +445,12 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu ...@@ -445,15 +445,12 @@ export class FilesRenderer implements ICompressibleTreeRenderer<ExplorerItem, Fu
DOM.addStandardDisposableListener(inputBox.inputElement, DOM.EventType.KEY_UP, (e: IKeyboardEvent) => { DOM.addStandardDisposableListener(inputBox.inputElement, DOM.EventType.KEY_UP, (e: IKeyboardEvent) => {
showInputBoxNotification(); showInputBoxNotification();
}), }),
DOM.addDisposableListener(inputBox.inputElement, DOM.EventType.BLUR, () => {
done(inputBox.isInputValid(), true);
}),
label, label,
styler 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(() => { return toDisposable(() => {
done(false, false); done(false, false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册