Skip to content

Commit 45cfb41

Browse files
committed
Merge stage and track into a single command in the browser context menu
1 parent c3fd4c6 commit 45cfb41

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/commandsAndMenu.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,21 @@ export function addCommands(
505505
icon: diffIcon
506506
});
507507

508+
commands.addCommand(ContextCommandIDs.gitFileAdd, {
509+
label: 'Add',
510+
caption: pluralizedContextLabel(
511+
'Stage or track the changes to selected file',
512+
'Stage or track the changes of selected files'
513+
),
514+
execute: async args => {
515+
const { files } = (args as any) as CommandArguments.IGitContextAction;
516+
for (const file of files) {
517+
await model.add(file.to);
518+
}
519+
},
520+
icon: addIcon
521+
});
522+
508523
commands.addCommand(ContextCommandIDs.gitFileStage, {
509524
label: 'Stage',
510525
caption: pluralizedContextLabel(
@@ -869,6 +884,13 @@ export function addFileBrowserContextMenu(
869884
command !== ContextCommandIDs.gitFileDelete &&
870885
typeof command !== 'undefined'
871886
)
887+
// replace stage and track with a single "add" operation
888+
.map(command =>
889+
command === ContextCommandIDs.gitFileStage ||
890+
command === ContextCommandIDs.gitFileTrack
891+
? ContextCommandIDs.gitFileAdd
892+
: command
893+
)
872894
);
873895

874896
// if looking at a tracked file with no changes,

src/tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ export interface ILogMessage {
835835
* The command IDs used in the git context menus.
836836
*/
837837
export enum ContextCommandIDs {
838+
gitFileAdd = 'git:context-add',
838839
gitFileDiff = 'git:context-diff',
839840
gitFileDiscard = 'git:context-discard',
840841
gitFileDelete = 'git:context-delete',

0 commit comments

Comments
 (0)