Skip to content

Commit 18368ca

Browse files
committed
Changes stash save icon
Renames existing stash save command Adds new stash save command (per file)
1 parent 326eb62 commit 18368ca

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [Unreleased]
88

9+
### Changed
10+
11+
- Renames the _Stash Changes_ command (`gitlens.stashSave`) to _Stash All Changes_ and adds a new _Stash Changes_ command (`gitlens.stashSaveFiles`)
12+
- Changes the icon of the _Stash All Changes_ command (`gitlens.stashSave`) — closes [Microsoft/vscode#64423](https://github.com/Microsoft/vscode/issues/64423)
13+
914
### Fixed
1015

1116
- Fixes [#598](https://github.com/eamodio/vscode-gitlens/issues/598) — Apply changes when comparing a file from two branches is not working

images/dark/icon-stash-save.svg

Lines changed: 2 additions & 2 deletions
Loading

images/light/icon-stash-save.svg

Lines changed: 2 additions & 2 deletions
Loading

package.json

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,6 +2077,15 @@
20772077
},
20782078
{
20792079
"command": "gitlens.stashSave",
2080+
"title": "Stash All Changes",
2081+
"category": "GitLens",
2082+
"icon": {
2083+
"dark": "images/dark/icon-stash-save.svg",
2084+
"light": "images/light/icon-stash-save.svg"
2085+
}
2086+
},
2087+
{
2088+
"command": "gitlens.stashSaveFiles",
20802089
"title": "Stash Changes",
20812090
"category": "GitLens",
20822091
"icon": {
@@ -2900,6 +2909,10 @@
29002909
"command": "gitlens.stashSave",
29012910
"when": "gitlens:enabled && !gitlens:readonly"
29022911
},
2912+
{
2913+
"command": "gitlens.stashSaveFiles",
2914+
"when": "false"
2915+
},
29032916
{
29042917
"command": "gitlens.resetSuppressedWarnings",
29052918
"when": "gitlens:enabled"
@@ -3504,7 +3517,7 @@
35043517
"group": "1_gitlens_1@2"
35053518
},
35063519
{
3507-
"command": "gitlens.stashSave",
3520+
"command": "gitlens.stashSaveFiles",
35083521
"when": "gitlens:enabled && !gitlens:readonly && config.gitlens.menus.scmItem.stash",
35093522
"group": "1_modification@-1"
35103523
},
@@ -3955,7 +3968,7 @@
39553968
"group": "1_gitlens@1"
39563969
},
39573970
{
3958-
"command": "gitlens.stashSave",
3971+
"command": "gitlens.stashSaveFiles",
39593972
"when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b.*:(un)?staged\\b/",
39603973
"group": "1_gitlens@2"
39613974
},
@@ -4202,24 +4215,24 @@
42024215
"when": "viewItem == gitlens:search:results",
42034216
"group": "2_gitlens@1"
42044217
},
4205-
{
4206-
"command": "gitlens.stashApply",
4207-
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
4208-
"group": "inline@98"
4209-
},
42104218
{
42114219
"command": "gitlens.stashSave",
42124220
"when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/",
4213-
"group": "inline@99"
4221+
"group": "inline@98"
42144222
},
42154223
{
42164224
"command": "gitlens.stashApply",
42174225
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
4218-
"group": "1_gitlens@1"
4226+
"group": "inline@99"
42194227
},
42204228
{
42214229
"command": "gitlens.stashSave",
42224230
"when": "!gitlens:readonly && viewItem =~ /^gitlens:(stashes|status:files)$/",
4231+
"group": "1_gitlens@1"
4232+
},
4233+
{
4234+
"command": "gitlens.stashApply",
4235+
"when": "!gitlens:readonly && viewItem == gitlens:stashes",
42234236
"group": "1_gitlens@2"
42244237
},
42254238
{

src/commands/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export enum Commands {
8080
StashApply = 'gitlens.stashApply',
8181
StashDelete = 'gitlens.stashDelete',
8282
StashSave = 'gitlens.stashSave',
83+
StashSaveFiles = 'gitlens.stashSaveFiles',
8384
SupportGitLens = 'gitlens.supportGitLens',
8485
SwitchMode = 'gitlens.switchMode',
8586
ToggleCodeLens = 'gitlens.toggleCodeLens',
@@ -286,6 +287,14 @@ export function isCommandViewContextWithRepo(
286287
return (context.node as ViewNode & { repo?: Repository }).repo instanceof Repository;
287288
}
288289

290+
export function isCommandViewContextWithRepoPath(
291+
context: CommandContext
292+
): context is CommandViewItemContext & { node: ViewNode & { repoPath: string } } {
293+
if (context.type !== 'viewItem') return false;
294+
295+
return typeof (context.node as ViewNode & { repoPath?: string }).repoPath === 'string';
296+
}
297+
289298
export type CommandContext =
290299
| CommandScmGroupsContext
291300
| CommandScmStatesContext

src/commands/stashSave.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
Commands,
1414
getRepoPathOrPrompt,
1515
isCommandViewContextWithFile,
16-
isCommandViewContextWithRepo
16+
isCommandViewContextWithRepo,
17+
isCommandViewContextWithRepoPath
1718
} from './common';
1819

1920
export interface StashSaveCommandArgs {
@@ -27,7 +28,7 @@ export interface StashSaveCommandArgs {
2728
@command()
2829
export class StashSaveCommand extends Command {
2930
constructor() {
30-
super(Commands.StashSave);
31+
super([Commands.StashSave, Commands.StashSaveFiles]);
3132
}
3233

3334
protected async preExecute(context: CommandContext, args: StashSaveCommandArgs = {}): Promise<any> {
@@ -39,6 +40,10 @@ export class StashSaveCommand extends Command {
3940
args = { ...args };
4041
args.repoPath = context.node.repo.path;
4142
}
43+
else if (isCommandViewContextWithRepoPath(context)) {
44+
args = { ...args };
45+
args.repoPath = context.node.repoPath;
46+
}
4247
else if (context.type === 'scm-states') {
4348
args = { ...args };
4449
args.uris = context.scmResourceStates.map(s => s.resourceUri);

0 commit comments

Comments
 (0)