Skip to content

Commit

Permalink
fixes #71315
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed Sep 18, 2020
1 parent cca934d commit 26f6d2b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/vs/workbench/contrib/files/browser/views/explorerView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,10 +588,15 @@ export class ExplorerView extends ViewPane {
return this.tree.updateChildren(toRefresh, recursive);
}

focusNextIfItemFocused(item: ExplorerItem): void {
focusNeighbourIfItemFocused(item: ExplorerItem): void {
const focus = this.tree.getFocus();
if (focus.length === 1 && focus[0] === item) {
this.tree.focusNext();
const newFocus = this.tree.getFocus();
if (newFocus.length === 1 && newFocus[0] === item) {
// There was no next item to focus, focus the previous one
this.tree.focusPrevious();
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/files/common/explorerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class ExplorerService implements IExplorerService {
const parent = element.parent;
// Remove Element from Parent (Model)
parent.removeChild(element);
this.view?.focusNextIfItemFocused(element);
this.view?.focusNeighbourIfItemFocused(element);
// Refresh Parent (View)
await this.view?.refresh(false, parent);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface IExplorerView {
setTreeInput(): Promise<void>;
itemsCopied(tats: ExplorerItem[], cut: boolean, previousCut: ExplorerItem[] | undefined): void;
setEditable(stat: ExplorerItem, isEditing: boolean): Promise<void>;
focusNextIfItemFocused(item: ExplorerItem): void;
focusNeighbourIfItemFocused(item: ExplorerItem): void;
}

export const IExplorerService = createDecorator<IExplorerService>('explorerService');
Expand Down

0 comments on commit 26f6d2b

Please sign in to comment.