Skip to content

Commit 5788d07

Browse files
committed
Adds _Open All Changes [with Working Tree], Individually_ commands
1 parent 7d90d7e commit 5788d07

File tree

5 files changed

+164
-32
lines changed

5 files changed

+164
-32
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2626
- Adds experimental `gitlens.experimental.openChangesInMultiDiffEditor` setting to specify whether to open multiple changes in VS Code's experimental multi-diff editor (single tab) or in individual diff editors (multiple tabs)
2727
- Adds an inline _Open All Changes_ command to commits, stashes, and comparisons in the views
2828
- Changes _Open All Changes_ & _Open All Changes with Working Tree_ commands to use the new multi-diff editor when enabled
29+
- Adds _Open All Changes, Individually_ & _Open All Changes with Working Tree, Individually_ commands to provide access to the previous behavior
2930
- Requires VS Code `1.85` or later and `multiDiffEditor.experimental.enabled` to be enabled
3031
- Adds a confirmation prompt when attempting to undo a commit with uncommitted changes
3132
- Adds a _[Show|Hide] Merge Commits_ toggle to the _Contributors_ view

package.json

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6486,6 +6486,16 @@
64866486
"icon": "$(diff-multiple)",
64876487
"category": "GitLens"
64886488
},
6489+
{
6490+
"command": "gitlens.views.openChangedFileDiffsIndividually",
6491+
"title": "Open All Changes, Individually",
6492+
"category": "GitLens"
6493+
},
6494+
{
6495+
"command": "gitlens.views.openChangedFileDiffsWithWorkingIndividually",
6496+
"title": "Open All Changes with Working Tree, Individually",
6497+
"category": "GitLens"
6498+
},
64896499
{
64906500
"command": "gitlens.views.openChangedFileRevisions",
64916501
"title": "Open Files at Revision",
@@ -8179,6 +8189,16 @@
81798189
"icon": "$(diff-multiple)",
81808190
"category": "GitLens"
81818191
},
8192+
{
8193+
"command": "gitlens.graph.openChangedFileDiffsIndividually",
8194+
"title": "Open All Changes Individually",
8195+
"category": "GitLens"
8196+
},
8197+
{
8198+
"command": "gitlens.graph.openChangedFileDiffsWithWorkingIndividually",
8199+
"title": "Open All Changes with Working Tree Individually",
8200+
"category": "GitLens"
8201+
},
81828202
{
81838203
"command": "gitlens.graph.openChangedFileRevisions",
81848204
"title": "Open Files at Revision",
@@ -9611,6 +9631,14 @@
96119631
"command": "gitlens.views.openChangedFileDiffsWithWorking",
96129632
"when": "false"
96139633
},
9634+
{
9635+
"command": "gitlens.views.openChangedFileDiffsIndividually",
9636+
"when": "false"
9637+
},
9638+
{
9639+
"command": "gitlens.views.openChangedFileDiffsWithWorkingIndividually",
9640+
"when": "false"
9641+
},
96149642
{
96159643
"command": "gitlens.views.openChangedFileRevisions",
96169644
"when": "false"
@@ -10783,6 +10811,14 @@
1078310811
"command": "gitlens.graph.openChangedFileDiffsWithWorking",
1078410812
"when": "false"
1078510813
},
10814+
{
10815+
"command": "gitlens.graph.openChangedFileDiffsIndividually",
10816+
"when": "false"
10817+
},
10818+
{
10819+
"command": "gitlens.graph.openChangedFileDiffsWithWorkingIndividually",
10820+
"when": "false"
10821+
},
1078610822
{
1078710823
"command": "gitlens.graph.openChangedFileRevisions",
1078810824
"when": "false"
@@ -14290,9 +14326,19 @@
1429014326
"group": "1_gitlens@1"
1429114327
},
1429214328
{
14293-
"command": "gitlens.views.openChangedFileDiffsWithWorking",
14329+
"command": "gitlens.views.openChangedFileDiffsIndividually",
14330+
"when": "config.gitlens.experimental.openChangesInMultiDiffEditor",
1429414331
"group": "1_gitlens@2"
1429514332
},
14333+
{
14334+
"command": "gitlens.views.openChangedFileDiffsWithWorking",
14335+
"group": "1_gitlens@3"
14336+
},
14337+
{
14338+
"command": "gitlens.views.openChangedFileDiffsWithWorkingIndividually",
14339+
"when": "config.gitlens.experimental.openChangesInMultiDiffEditor",
14340+
"group": "1_gitlens@4"
14341+
},
1429614342
{
1429714343
"command": "gitlens.views.openChangedFiles",
1429814344
"group": "2_gitlens@1"
@@ -14311,10 +14357,20 @@
1431114357
"command": "gitlens.graph.openChangedFileDiffs",
1431214358
"group": "1_gitlens@1"
1431314359
},
14360+
{
14361+
"command": "gitlens.graph.openChangedFileDiffsIndividually",
14362+
"when": "config.gitlens.experimental.openChangesInMultiDiffEditor",
14363+
"group": "1_gitlens@2"
14364+
},
1431414365
{
1431514366
"command": "gitlens.graph.openChangedFileDiffsWithWorking",
1431614367
"when": "webviewItem != gitlens:wip",
14317-
"group": "1_gitlens@2"
14368+
"group": "1_gitlens@3"
14369+
},
14370+
{
14371+
"command": "gitlens.graph.openChangedFileDiffsWithWorkingIndividually",
14372+
"when": "config.gitlens.experimental.openChangesInMultiDiffEditor",
14373+
"group": "1_gitlens@4"
1431814374
},
1431914375
{
1432014376
"command": "gitlens.graph.openChangedFiles",

src/git/actions/commit.ts

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,30 @@ export async function openAllChanges(
105105
refsOrOptions: RefRange | TextDocumentShowOptions | undefined,
106106
maybeOptions?: TextDocumentShowOptions,
107107
): Promise<void> {
108-
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
109-
if (isCommit(commitOrFiles)) {
110-
return openAllChangesEditor(commitOrFiles, refsOrOptions as TextDocumentShowOptions | undefined);
108+
if (isCommit(commitOrFiles)) {
109+
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
110+
return openAllChangesInChangesEditor(commitOrFiles, refsOrOptions as TextDocumentShowOptions | undefined);
111111
}
112-
return openAllChangesEditor(commitOrFiles, refsOrOptions as RefRange, maybeOptions);
112+
return openAllChangesIndividually(commitOrFiles, refsOrOptions as TextDocumentShowOptions | undefined);
113+
}
114+
115+
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
116+
return openAllChangesInChangesEditor(commitOrFiles, refsOrOptions as RefRange, maybeOptions);
113117
}
118+
return openAllChangesIndividually(commitOrFiles, refsOrOptions as RefRange, maybeOptions);
119+
}
114120

121+
export async function openAllChangesIndividually(commit: GitCommit, options?: TextDocumentShowOptions): Promise<void>;
122+
export async function openAllChangesIndividually(
123+
files: GitFile[],
124+
refs: RefRange,
125+
options?: TextDocumentShowOptions,
126+
): Promise<void>;
127+
export async function openAllChangesIndividually(
128+
commitOrFiles: GitCommit | GitFile[],
129+
refsOrOptions: RefRange | TextDocumentShowOptions | undefined,
130+
maybeOptions?: TextDocumentShowOptions,
131+
): Promise<void> {
115132
let { files, refs, options } = await getChangesRefsArgs(commitOrFiles, refsOrOptions, maybeOptions);
116133

117134
if (
@@ -131,16 +148,16 @@ export async function openAllChanges(
131148
}
132149
}
133150

134-
export async function openAllChangesEditor(
151+
export async function openAllChangesInChangesEditor(
135152
commit: GitCommit,
136153
options?: TextDocumentShowOptions & { title?: string },
137154
): Promise<void>;
138-
export async function openAllChangesEditor(
155+
export async function openAllChangesInChangesEditor(
139156
files: GitFile[],
140157
refs: RefRange,
141158
options?: TextDocumentShowOptions & { title?: string },
142159
): Promise<void>;
143-
export async function openAllChangesEditor(
160+
export async function openAllChangesInChangesEditor(
144161
commitOrFiles: GitCommit | GitFile[],
145162
refsOrOptions: RefRange | (TextDocumentShowOptions & { title?: string }) | undefined,
146163
maybeOptions?: TextDocumentShowOptions & { title?: string },
@@ -231,12 +248,18 @@ export async function openAllChangesWithWorking(
231248
refOrOptions: Ref | TextDocumentShowOptions | undefined,
232249
maybeOptions?: TextDocumentShowOptions,
233250
) {
234-
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
235-
if (isCommit(commitOrFiles)) {
236-
return openAllChangesEditor(commitOrFiles, refOrOptions as TextDocumentShowOptions | undefined);
251+
if (isCommit(commitOrFiles)) {
252+
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
253+
return openAllChangesInChangesEditor(commitOrFiles, refOrOptions as TextDocumentShowOptions | undefined);
237254
}
255+
return openAllChangesWithWorkingIndividually(
256+
commitOrFiles,
257+
refOrOptions as TextDocumentShowOptions | undefined,
258+
);
259+
}
238260

239-
return openAllChangesEditor(
261+
if (configuration.get('experimental.openChangesInMultiDiffEditor')) {
262+
return openAllChangesInChangesEditor(
240263
commitOrFiles,
241264
{
242265
repoPath: (refOrOptions as Ref).repoPath,
@@ -246,7 +269,23 @@ export async function openAllChangesWithWorking(
246269
maybeOptions,
247270
);
248271
}
272+
return openAllChangesWithWorkingIndividually(commitOrFiles, refOrOptions as Ref, maybeOptions);
273+
}
249274

275+
export async function openAllChangesWithWorkingIndividually(
276+
commit: GitCommit,
277+
options?: TextDocumentShowOptions,
278+
): Promise<void>;
279+
export async function openAllChangesWithWorkingIndividually(
280+
files: GitFile[],
281+
ref: Ref,
282+
options?: TextDocumentShowOptions,
283+
): Promise<void>;
284+
export async function openAllChangesWithWorkingIndividually(
285+
commitOrFiles: GitCommit | GitFile[],
286+
refOrOptions: Ref | TextDocumentShowOptions | undefined,
287+
maybeOptions?: TextDocumentShowOptions,
288+
) {
250289
let { files, ref, options } = await getChangesRefArgs(commitOrFiles, refOrOptions, maybeOptions);
251290

252291
if (
@@ -453,7 +492,7 @@ export async function openFolderCompare(
453492
strings: { working: 'Working Tree' },
454493
})} ${GlyphChars.ArrowLeftRightLong} ${shortenRevision(refs.rhs, { strings: { working: 'Working Tree' } })}`;
455494

456-
return openAllChangesEditor(files, refs, { ...options, title: title });
495+
return openAllChangesInChangesEditor(files, refs, { ...options, title: title });
457496
}
458497

459498
export async function openFile(uri: Uri, options?: TextDocumentShowOptions): Promise<void>;

src/plus/webviews/graph/graphWebview.ts

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import { PlusFeatures } from '../../../features';
1919
import * as BranchActions from '../../../git/actions/branch';
2020
import {
2121
openAllChanges,
22+
openAllChangesIndividually,
2223
openAllChangesWithWorking,
24+
openAllChangesWithWorkingIndividually,
2325
openFiles,
2426
openFilesAtRevision,
2527
openOnlyChangedFiles,
@@ -63,12 +65,7 @@ import {
6365
import type { GitSearch } from '../../../git/search';
6466
import { getSearchQueryComparisonKey } from '../../../git/search';
6567
import { showRepositoryPicker } from '../../../quickpicks/repositoryPicker';
66-
import {
67-
executeActionCommand,
68-
executeCommand,
69-
executeCoreCommand,
70-
registerCommand,
71-
} from '../../../system/command';
68+
import { executeActionCommand, executeCommand, executeCoreCommand, registerCommand } from '../../../system/command';
7269
import { configuration } from '../../../system/configuration';
7370
import { getContext, onDidChangeContext } from '../../../system/context';
7471
import { gate } from '../../../system/decorators/gate';
@@ -534,10 +531,18 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
534531

535532
this.host.registerWebviewCommand('gitlens.graph.openChangedFiles', this.openFiles),
536533
this.host.registerWebviewCommand('gitlens.graph.openOnlyChangedFiles', this.openOnlyChangedFiles),
537-
this.host.registerWebviewCommand('gitlens.graph.openChangedFileDiffs', this.openAllChanges),
538-
this.host.registerWebviewCommand(
539-
'gitlens.graph.openChangedFileDiffsWithWorking',
540-
this.openAllChangesWithWorking,
534+
this.host.registerWebviewCommand<GraphItemContext>('gitlens.graph.openChangedFileDiffs', item =>
535+
this.openAllChanges(item),
536+
),
537+
this.host.registerWebviewCommand<GraphItemContext>('gitlens.graph.openChangedFileDiffsWithWorking', item =>
538+
this.openAllChangesWithWorking(item),
539+
),
540+
this.host.registerWebviewCommand<GraphItemContext>('gitlens.graph.openChangedFileDiffsIndividually', item =>
541+
this.openAllChanges(item, true),
542+
),
543+
this.host.registerWebviewCommand<GraphItemContext>(
544+
'gitlens.graph.openChangedFileDiffsWithWorkingIndividually',
545+
item => this.openAllChangesWithWorking(item, true),
541546
),
542547
this.host.registerWebviewCommand('gitlens.graph.openChangedFileRevisions', this.openRevisions),
543548

@@ -2714,18 +2719,24 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
27142719
}
27152720

27162721
@debug()
2717-
private async openAllChanges(item?: GraphItemContext) {
2722+
private async openAllChanges(item?: GraphItemContext, individually?: boolean) {
27182723
const commit = await this.getCommitFromGraphItemRef(item);
27192724
if (commit == null) return;
27202725

2726+
if (individually) {
2727+
return openAllChangesIndividually(commit);
2728+
}
27212729
return openAllChanges(commit);
27222730
}
27232731

27242732
@debug()
2725-
private async openAllChangesWithWorking(item?: GraphItemContext) {
2733+
private async openAllChangesWithWorking(item?: GraphItemContext, individually?: boolean) {
27262734
const commit = await this.getCommitFromGraphItemRef(item);
27272735
if (commit == null) return;
27282736

2737+
if (individually) {
2738+
return openAllChangesWithWorkingIndividually(commit);
2739+
}
27292740
return openAllChangesWithWorking(commit);
27302741
}
27312742

src/views/viewCommands.ts

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,22 @@ export class ViewCommands {
218218
registerViewCommand('gitlens.views.openFileRevision', this.openRevision, this);
219219
registerViewCommand('gitlens.views.openChangedFiles', this.openFiles, this);
220220
registerViewCommand('gitlens.views.openOnlyChangedFiles', this.openOnlyChangedFiles);
221-
registerViewCommand('gitlens.views.openChangedFileDiffs', this.openAllChanges, this);
222-
registerViewCommand('gitlens.views.openChangedFileDiffsWithWorking', this.openAllChangesWithWorking, this);
221+
registerViewCommand('gitlens.views.openChangedFileDiffs', (n, o) => this.openAllChanges(n, o), this);
222+
registerViewCommand(
223+
'gitlens.views.openChangedFileDiffsWithWorking',
224+
(n, o) => this.openAllChangesWithWorking(n, o),
225+
this,
226+
);
227+
registerViewCommand(
228+
'gitlens.views.openChangedFileDiffsIndividually',
229+
(n, o) => this.openAllChanges(n, o, true),
230+
this,
231+
);
232+
registerViewCommand(
233+
'gitlens.views.openChangedFileDiffsWithWorkingIndividually',
234+
(n, o) => this.openAllChangesWithWorking(n, o, true),
235+
this,
236+
);
223237
registerViewCommand('gitlens.views.openChangedFileRevisions', this.openRevisions, this);
224238
registerViewCommand('gitlens.views.applyChanges', this.applyChanges, this);
225239
registerViewCommand('gitlens.views.highlightChanges', this.highlightChanges, this);
@@ -1004,6 +1018,7 @@ export class ViewCommands {
10041018
private async openAllChanges(
10051019
node: CompareResultsNode | CommitNode | StashNode | ResultsFilesNode,
10061020
options?: TextDocumentShowOptions,
1021+
individually?: boolean,
10071022
) {
10081023
if (node.is('compare-results')) {
10091024
node = (await node.getFilesNode())!;
@@ -1014,7 +1029,7 @@ export class ViewCommands {
10141029
const { files } = await node.getFilesQueryResults();
10151030
if (!files?.length) return undefined;
10161031

1017-
return CommitActions.openAllChanges(
1032+
return (individually ? CommitActions.openAllChangesIndividually : CommitActions.openAllChanges)(
10181033
files,
10191034
{
10201035
repoPath: node.repoPath,
@@ -1027,7 +1042,10 @@ export class ViewCommands {
10271042

10281043
if (!node.isAny('commit', 'stash')) return undefined;
10291044

1030-
return CommitActions.openAllChanges(node.commit, options);
1045+
return (individually ? CommitActions.openAllChangesIndividually : CommitActions.openAllChanges)(
1046+
node.commit,
1047+
options,
1048+
);
10311049
}
10321050

10331051
@log()
@@ -1086,6 +1104,7 @@ export class ViewCommands {
10861104
private async openAllChangesWithWorking(
10871105
node: CompareResultsNode | CommitNode | StashNode | ResultsFilesNode,
10881106
options?: TextDocumentShowOptions,
1107+
individually?: boolean,
10891108
) {
10901109
if (node.is('compare-results')) {
10911110
node = (await node.getFilesNode())!;
@@ -1096,7 +1115,11 @@ export class ViewCommands {
10961115
const { files } = await node.getFilesQueryResults();
10971116
if (!files?.length) return undefined;
10981117

1099-
return CommitActions.openAllChangesWithWorking(
1118+
return (
1119+
individually
1120+
? CommitActions.openAllChangesWithWorkingIndividually
1121+
: CommitActions.openAllChangesWithWorking
1122+
)(
11001123
files,
11011124
{
11021125
repoPath: node.repoPath,
@@ -1108,7 +1131,9 @@ export class ViewCommands {
11081131

11091132
if (!node.isAny('commit', 'stash')) return undefined;
11101133

1111-
return CommitActions.openAllChangesWithWorking(node.commit, options);
1134+
return (
1135+
individually ? CommitActions.openAllChangesWithWorkingIndividually : CommitActions.openAllChangesWithWorking
1136+
)(node.commit, options);
11121137
}
11131138

11141139
@log()

0 commit comments

Comments
 (0)