提交 b0a913b7 编写于 作者: I isidor

explorer: Should maintain row focus after deleting a file

fixes #71315
上级 133d95e6
......@@ -588,6 +588,13 @@ export class ExplorerView extends ViewPane {
return this.tree.updateChildren(toRefresh, recursive);
}
focusNextIfItemFocused(item: ExplorerItem): void {
const focus = this.tree.getFocus();
if (focus.length === 1 && focus[0] === item) {
this.tree.focusNext();
}
}
getOptimalWidth(): number {
const parentNode = this.tree.getHTMLElement();
const childNodes = ([] as HTMLElement[]).slice.call(parentNode.querySelectorAll('.explorer-item .label-name')); // select all file labels
......
......@@ -278,6 +278,7 @@ export class ExplorerService implements IExplorerService {
const parent = element.parent;
// Remove Element from Parent (Model)
parent.removeChild(element);
this.view?.focusNextIfItemFocused(element);
// Refresh Parent (View)
await this.view?.refresh(false, parent);
}
......
......@@ -65,6 +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;
}
export const IExplorerService = createDecorator<IExplorerService>('explorerService');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册