提交 34b88074 编写于 作者: I isidor

explorer: if no file is focused respect the selection

fixes #84484
上级 8afb6397
......@@ -77,7 +77,7 @@ const MOVE_FILE_TO_TRASH_ID = 'moveFileToTrash';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: MOVE_FILE_TO_TRASH_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext, ExplorerResourceMoveableToTrash),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext, ExplorerResourceMoveableToTrash),
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace
......@@ -89,7 +89,7 @@ const DELETE_FILE_ID = 'deleteFile';
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: DELETE_FILE_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext),
primary: KeyMod.Shift | KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Backspace
......@@ -100,7 +100,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: DELETE_FILE_ID,
weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus,
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerRootContext.toNegated(), ExplorerResourceNotReadonlyContext, ExplorerResourceMoveableToTrash.toNegated()),
when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerResourceNotReadonlyContext, ExplorerResourceMoveableToTrash.toNegated()),
primary: KeyCode.Delete,
mac: {
primary: KeyMod.CtrlCmd | KeyCode.Backspace
......
......@@ -937,17 +937,21 @@ export const renameHandler = (accessor: ServicesAccessor) => {
});
};
export const moveFileToTrashHandler = (accessor: ServicesAccessor) => {
export const moveFileToTrashHandler = async (accessor: ServicesAccessor) => {
const explorerService = accessor.get(IExplorerService);
const stats = explorerService.getContext(true);
return deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, true);
const stats = explorerService.getContext(true).filter(s => !s.isRoot);
if (stats.length) {
await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, true);
}
};
export const deleteFileHandler = (accessor: ServicesAccessor) => {
export const deleteFileHandler = async (accessor: ServicesAccessor) => {
const explorerService = accessor.get(IExplorerService);
const stats = explorerService.getContext(true);
const stats = explorerService.getContext(true).filter(s => !s.isRoot);
return deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, false);
if (stats.length) {
await deleteFiles(accessor.get(ITextFileService), accessor.get(IDialogService), accessor.get(IConfigurationService), accessor.get(IFileService), stats, false);
}
};
let pasteShouldMove = false;
......
......@@ -293,10 +293,6 @@ export class ExplorerView extends ViewletPanel {
focusedStat = focus.length ? focus[0] : undefined;
}
if (!focusedStat) {
return [];
}
const selectedStats: ExplorerItem[] = [];
for (const stat of this.tree.getSelection()) {
......@@ -308,6 +304,13 @@ export class ExplorerView extends ViewletPanel {
selectedStats.push(stat);
}
}
if (!focusedStat) {
if (respectMultiSelection) {
return selectedStats;
} else {
return [];
}
}
if (respectMultiSelection && selectedStats.indexOf(focusedStat) >= 0) {
return selectedStats;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册