diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d61671..99ec18e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [Unreleased] +### Changed + +- Renames the _Stash Changes_ command (`gitlens.stashSave`) to _Stash All Changes_ and adds a new _Stash Changes_ command (`gitlens.stashSaveFiles`) +- Changes the icon of the _Stash All Changes_ command (`gitlens.stashSave`) — closes [Microsoft/vscode#64423](https://github.com/Microsoft/vscode/issues/64423) + ### Fixed - Fixes [#598](https://github.com/eamodio/vscode-gitlens/issues/598) — Apply changes when comparing a file from two branches is not working diff --git a/images/dark/icon-stash-save.svg b/images/dark/icon-stash-save.svg index a11b871..d3cd329 100644 --- a/images/dark/icon-stash-save.svg +++ b/images/dark/icon-stash-save.svg @@ -1,5 +1,5 @@ - - + + diff --git a/images/light/icon-stash-save.svg b/images/light/icon-stash-save.svg index 5a7f990..d8f9660 100644 --- a/images/light/icon-stash-save.svg +++ b/images/light/icon-stash-save.svg @@ -1,5 +1,5 @@ - - + + diff --git a/package.json b/package.json index 0e8d7a7..c58c43b 100644 --- a/package.json +++ b/package.json @@ -2077,6 +2077,15 @@ }, { "command": "gitlens.stashSave", + "title": "Stash All Changes", + "category": "GitLens", + "icon": { + "dark": "images/dark/icon-stash-save.svg", + "light": "images/light/icon-stash-save.svg" + } + }, + { + "command": "gitlens.stashSaveFiles", "title": "Stash Changes", "category": "GitLens", "icon": { @@ -2901,6 +2910,10 @@ "when": "gitlens:enabled && !gitlens:readonly" }, { + "command": "gitlens.stashSaveFiles", + "when": "false" + }, + { "command": "gitlens.resetSuppressedWarnings", "when": "gitlens:enabled" }, @@ -3504,7 +3517,7 @@ "group": "1_gitlens_1@2" }, { - "command": "gitlens.stashSave", + "command": "gitlens.stashSaveFiles", "when": "gitlens:enabled && !gitlens:readonly && config.gitlens.menus.scmItem.stash", "group": "1_modification@-1" }, @@ -3955,7 +3968,7 @@ "group": "1_gitlens@1" }, { - "command": "gitlens.stashSave", + "command": "gitlens.stashSaveFiles", "when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b.*:(un)?staged\\b/", "group": "1_gitlens@2" }, @@ -4203,23 +4216,23 @@ "group": "2_gitlens@1" }, { - "command": "gitlens.stashApply", - "when": "!gitlens:readonly && viewItem == gitlens:stashes", - "group": "inline@98" - }, - { "command": "gitlens.stashSave", "when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/", - "group": "inline@99" + "group": "inline@98" }, { "command": "gitlens.stashApply", "when": "!gitlens:readonly && viewItem == gitlens:stashes", - "group": "1_gitlens@1" + "group": "inline@99" }, { "command": "gitlens.stashSave", "when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/", + "group": "1_gitlens@1" + }, + { + "command": "gitlens.stashApply", + "when": "!gitlens:readonly && viewItem == gitlens:stashes", "group": "1_gitlens@2" }, { diff --git a/src/commands/common.ts b/src/commands/common.ts index 6e5e210..7e969bf 100644 --- a/src/commands/common.ts +++ b/src/commands/common.ts @@ -80,6 +80,7 @@ export enum Commands { StashApply = 'gitlens.stashApply', StashDelete = 'gitlens.stashDelete', StashSave = 'gitlens.stashSave', + StashSaveFiles = 'gitlens.stashSaveFiles', SupportGitLens = 'gitlens.supportGitLens', SwitchMode = 'gitlens.switchMode', ToggleCodeLens = 'gitlens.toggleCodeLens', @@ -286,6 +287,14 @@ export function isCommandViewContextWithRepo( return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository; } +export function isCommandViewContextWithRepoPath( + context: CommandContext +): context is CommandViewItemContext & { node: ViewNode & { repoPath: string } } { + if (context.type !== 'viewItem') return false; + + return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string'; +} + export type CommandContext = | CommandScmGroupsContext | CommandScmStatesContext diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 724a70b..cc46354 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -13,7 +13,8 @@ import { Commands, getRepoPathOrPrompt, isCommandViewContextWithFile, - isCommandViewContextWithRepo + isCommandViewContextWithRepo, + isCommandViewContextWithRepoPath } from './common'; export interface StashSaveCommandArgs { @@ -27,7 +28,7 @@ export interface StashSaveCommandArgs { @command() export class StashSaveCommand extends Command { constructor() { - super(Commands.StashSave); + super([Commands.StashSave, Commands.StashSaveFiles]); } protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise { @@ -39,6 +40,10 @@ export class StashSaveCommand extends Command { args = { ...args }; args.repoPath = context.node.repo.path; } + else if (isCommandViewContextWithRepoPath(context)) { + args = { ...args }; + args.repoPath = context.node.repoPath; + } else if (context.type === 'scm-states') { args = { ...args }; args.uris = context.scmResourceStates.map(s => s.resourceUri);