From 5074016767b13263474f3c11cf5ed4ae1d7334a7 Mon Sep 17 00:00:00 2001 From: Astabol Date: Sat, 21 Dec 2024 21:33:00 +0530 Subject: [PATCH 1/2] Added "Make a Copy Here" in File Action --- .../files/browser/fileActions.contribution.ts | 20 ++++++++++++++++++- .../contrib/files/browser/fileActions.ts | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts b/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts index be7dddf26ff91..f672fcea63aa9 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from '../../../../nls.js'; -import { ToggleAutoSaveAction, FocusFilesExplorer, GlobalCompareResourcesAction, ShowActiveFileInExplorer, CompareWithClipboardAction, NEW_FILE_COMMAND_ID, NEW_FILE_LABEL, NEW_FOLDER_COMMAND_ID, NEW_FOLDER_LABEL, TRIGGER_RENAME_LABEL, MOVE_FILE_TO_TRASH_LABEL, COPY_FILE_LABEL, PASTE_FILE_LABEL, FileCopiedContext, renameHandler, moveFileToTrashHandler, copyFileHandler, pasteFileHandler, deleteFileHandler, cutFileHandler, DOWNLOAD_COMMAND_ID, openFilePreserveFocusHandler, DOWNLOAD_LABEL, OpenActiveFileInEmptyWorkspace, UPLOAD_COMMAND_ID, UPLOAD_LABEL, CompareNewUntitledTextFilesAction, SetActiveEditorReadonlyInSession, SetActiveEditorWriteableInSession, ToggleActiveEditorReadonlyInSession, ResetActiveEditorReadonlyInSession } from './fileActions.js'; +import { ToggleAutoSaveAction, FocusFilesExplorer, GlobalCompareResourcesAction, ShowActiveFileInExplorer, CompareWithClipboardAction, NEW_FILE_COMMAND_ID, NEW_FILE_LABEL, NEW_FOLDER_COMMAND_ID, NEW_FOLDER_LABEL, TRIGGER_RENAME_LABEL, MOVE_FILE_TO_TRASH_LABEL, COPY_FILE_LABEL, PASTE_FILE_LABEL, FileCopiedContext, renameHandler, moveFileToTrashHandler, copyFileHandler, pasteFileHandler, deleteFileHandler, cutFileHandler, DOWNLOAD_COMMAND_ID, openFilePreserveFocusHandler, DOWNLOAD_LABEL, OpenActiveFileInEmptyWorkspace, UPLOAD_COMMAND_ID, UPLOAD_LABEL, CompareNewUntitledTextFilesAction, SetActiveEditorReadonlyInSession, SetActiveEditorWriteableInSession, ToggleActiveEditorReadonlyInSession, ResetActiveEditorReadonlyInSession, copyPasteFileSameLocation } from './fileActions.js'; import { revertLocalChangesCommand, acceptLocalChangesCommand, CONFLICT_RESOLUTION_CONTEXT } from './editors/textFileSaveErrorHandler.js'; import { MenuId, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js'; import { ICommandAction } from '../../../../platform/action/common/action.js'; @@ -144,6 +144,14 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ handler: openFilePreserveFocusHandler }); +KeybindingsRegistry.registerCommandAndKeybindingRule({ + id: 'filesExplorer.copySameExp', + weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, + when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerFolderContext.toNegated()), + primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyC, + handler: copyPasteFileSameLocation, +}); + const copyPathCommand = { id: COPY_PATH_COMMAND_ID, title: nls.localize('copyPath', "Copy Path") @@ -553,6 +561,16 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { when: ExplorerRootContext.toNegated() }); +MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { + group: '5_cutcopypaste', + order: 10, + command: { + id: 'filesExplorer.copySameExp', + title: 'Make a Copy Here', + }, + when: ExplorerRootContext.toNegated() +}); + MenuRegistry.appendMenuItem(MenuId.ExplorerContext, { group: '5_cutcopypaste', order: 20, diff --git a/src/vs/workbench/contrib/files/browser/fileActions.ts b/src/vs/workbench/contrib/files/browser/fileActions.ts index 635765f09b75f..916a958968bf2 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.ts @@ -1312,6 +1312,11 @@ export const openFilePreserveFocusHandler = async (accessor: ServicesAccessor) = }))); }; +export const copyPasteFileSameLocation = async (accessor: ServicesAccessor) => { + copyFileHandler(accessor); + pasteFileHandler(accessor); +}; + class BaseSetActiveEditorReadonlyInSession extends Action2 { constructor( From ec20723fb60b63b322aa49578ae6a3a945eb1e32 Mon Sep 17 00:00:00 2001 From: Astabol Date: Sat, 21 Dec 2024 22:37:59 +0530 Subject: [PATCH 2/2] Removed Shortcut Keys --- .../workbench/contrib/files/browser/fileActions.contribution.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts b/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts index f672fcea63aa9..4e5e4ef42f9c9 100644 --- a/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/fileActions.contribution.ts @@ -148,7 +148,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ id: 'filesExplorer.copySameExp', weight: KeybindingWeight.WorkbenchContrib + explorerCommandsWeightBonus, when: ContextKeyExpr.and(FilesExplorerFocusCondition, ExplorerFolderContext.toNegated()), - primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyC, handler: copyPasteFileSameLocation, });