提交 43b39d5a 编写于 作者: M Miguel Solorio

Merge branch 'master' of github.com:Microsoft/vscode

......@@ -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;
......
......@@ -37,6 +37,9 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { UNTITLED_WORKSPACE_NAME } from 'vs/platform/workspaces/common/workspaces';
import { coalesce } from 'vs/base/common/arrays';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { EmbeddedCodeEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
// Commands
......@@ -310,11 +313,32 @@ CommandsRegistry.registerCommand({
// Save / Save As / Save All / Revert
function saveSelectedEditors(accessor: ServicesAccessor, options?: ISaveEditorsOptions): Promise<void> {
async function saveSelectedEditors(accessor: ServicesAccessor, options?: ISaveEditorsOptions): Promise<void> {
const listService = accessor.get(IListService);
const editorGroupsService = accessor.get(IEditorGroupsService);
return doSaveEditors(accessor, getMultiSelectedEditors(listService, editorGroupsService), options);
const codeEditorService = accessor.get(ICodeEditorService);
const textFileService = accessor.get(ITextFileService);
// Save editors
const editors = getMultiSelectedEditors(listService, editorGroupsService);
await doSaveEditors(accessor, editors, options);
// Special treatment for embedded editors: if we detect that focus is
// inside an embedded code editor, we save that model as well if we
// find it in our text file models. Currently, only textual editors
// support embedded editors.
const focusedCodeEditor = codeEditorService.getFocusedCodeEditor();
if (focusedCodeEditor instanceof EmbeddedCodeEditorWidget) {
const resource = focusedCodeEditor.getModel()?.uri;
// Check that the resource of the model was not saved already
if (resource && !editors.some(({ editor }) => isEqual(toResource(editor, { supportSideBySide: SideBySideEditor.MASTER }), resource))) {
const model = textFileService.models.get(resource);
if (!model?.isReadonly()) {
await textFileService.save(resource, options);
}
}
}
}
function saveDirtyEditorsOfGroups(accessor: ServicesAccessor, groups: ReadonlyArray<IEditorGroup>, options?: ISaveEditorsOptions): Promise<void> {
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册