Skip to content

Commit 5ae8ffb

Browse files
authored
SCM Graph - set the groundwork to show all history item groups (#227780)
1 parent bcb954e commit 5ae8ffb

File tree

4 files changed

+52
-15
lines changed

4 files changed

+52
-15
lines changed

extensions/git/src/git.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,9 @@ export class Repository {
11741174
}
11751175

11761176
if (options?.refNames) {
1177+
if (options.refNames.length === 0) {
1178+
args.push('--all');
1179+
}
11771180
args.push('--topo-order');
11781181
args.push('--decorate=full');
11791182
args.push(...options.refNames);

src/vs/base/browser/markdownRenderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ function sanitizeRenderedMarkdown(
396396
if (e.attrName === 'style' || e.attrName === 'class') {
397397
if (element.tagName === 'SPAN') {
398398
if (e.attrName === 'style') {
399-
e.keepAttr = /^(color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z]+)+\));)?(background-color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z]+)+\));)?(border-radius:[0-9]+px;)?$/.test(e.attrValue);
399+
e.keepAttr = /^(color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z0-9]+)+\));)?(background-color\:(#[0-9a-fA-F]+|var\(--vscode(-[a-zA-Z0-9]+)+\));)?(border-radius:[0-9]+px;)?$/.test(e.attrValue);
400400
return;
401401
} else if (e.attrName === 'class') {
402402
e.keepAttr = /^codicon codicon-[a-z\-]+( codicon-modifier-[a-z\-]+)?$/.test(e.attrValue);

src/vs/workbench/contrib/scm/browser/scmHistory.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,20 @@ export function toISCMHistoryItemViewModelArray(historyItems: ISCMHistoryItem[],
305305
// Add colors to labels
306306
const labels = (historyItem.labels ?? [])
307307
.map(label => {
308-
return { ...label, color: colorMap.get(label.title) };
308+
let color = colorMap.get(label.title);
309+
if (!color && colorMap.has('*')) {
310+
// Find the history item in the input swimlanes
311+
const inputIndex = inputSwimlanes.findIndex(node => node.id === historyItem.id);
312+
313+
// Circle index - use the input swimlane index if present, otherwise add it to the end
314+
const circleIndex = inputIndex !== -1 ? inputIndex : inputSwimlanes.length;
315+
316+
// Circle color - use the output swimlane color if present, otherwise the input swimlane color
317+
color = circleIndex < outputSwimlanes.length ? outputSwimlanes[circleIndex].color :
318+
circleIndex < inputSwimlanes.length ? inputSwimlanes[circleIndex].color : historyItemGroupLocal;
319+
}
320+
321+
return { ...label, color };
309322
});
310323

311324
viewModels.push({

src/vs/workbench/contrib/scm/browser/scmHistoryViewPane.ts

+34-13
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,33 @@ class SCMHistoryViewModel extends Disposable {
574574
* values are updated in the same transaction (or during the initial read of the observable value).
575575
*/
576576
readonly repository = latestChangedValue(this, [this._firstRepository, this._graphRepository]);
577-
private readonly _historyItemGroupIds = observableValue<'all' | 'auto' | string[]>(this, 'auto');
577+
578+
private readonly _historyItemGroupFilter = observableValue<'all' | 'auto' | string[]>(this, 'auto');
579+
580+
readonly historyItemGroupFilter = derived<string[]>(reader => {
581+
const filter = this._historyItemGroupFilter.read(reader);
582+
if (Array.isArray(filter)) {
583+
return filter;
584+
}
585+
586+
if (filter === 'all') {
587+
return [];
588+
}
589+
590+
const repository = this.repository.get();
591+
const historyProvider = repository?.provider.historyProvider.get();
592+
const currentHistoryItemGroup = historyProvider?.currentHistoryItemGroup.get();
593+
594+
if (!currentHistoryItemGroup) {
595+
return [];
596+
}
597+
598+
return [
599+
currentHistoryItemGroup.revision ?? currentHistoryItemGroup.id,
600+
...currentHistoryItemGroup.remote ? [currentHistoryItemGroup.remote.revision ?? currentHistoryItemGroup.remote.id] : [],
601+
...currentHistoryItemGroup.base ? [currentHistoryItemGroup.base.revision ?? currentHistoryItemGroup.base.id] : [],
602+
];
603+
});
578604

579605
private readonly _state = new Map<ISCMRepository, HistoryItemState>();
580606

@@ -633,13 +659,9 @@ class SCMHistoryViewModel extends Disposable {
633659
}
634660

635661
if (!state || state.loadMore) {
636-
const historyItemGroupIds = [
637-
currentHistoryItemGroup.revision ?? currentHistoryItemGroup.id,
638-
...currentHistoryItemGroup.remote ? [currentHistoryItemGroup.remote.revision ?? currentHistoryItemGroup.remote.id] : [],
639-
...currentHistoryItemGroup.base ? [currentHistoryItemGroup.base.revision ?? currentHistoryItemGroup.base.id] : [],
640-
];
641-
642662
const existingHistoryItems = state?.items ?? [];
663+
664+
const historyItemGroupIds = this.historyItemGroupFilter.get();
643665
const limit = clamp(this._configurationService.getValue<number>('scm.graph.pageSize'), 1, 1000);
644666

645667
const historyItems = await historyProvider.provideHistoryItems({
@@ -656,7 +678,7 @@ class SCMHistoryViewModel extends Disposable {
656678
}
657679

658680
// Create the color map
659-
const colorMap = this._getHistoryItemsColorMap(currentHistoryItemGroup);
681+
const colorMap = this._getGraphColorMap(currentHistoryItemGroup);
660682

661683
return toISCMHistoryItemViewModelArray(state.items, colorMap)
662684
.map(historyItemViewModel => ({
@@ -670,11 +692,7 @@ class SCMHistoryViewModel extends Disposable {
670692
this._selectedRepository.set(repository, undefined);
671693
}
672694

673-
private _getHistoryItemsColorMap(currentHistoryItemGroup: ISCMHistoryItemGroup): Map<string, ColorIdentifier> {
674-
if (this._historyItemGroupIds.get() !== 'auto') {
675-
return new Map<string, ColorIdentifier>();
676-
}
677-
695+
private _getGraphColorMap(currentHistoryItemGroup: ISCMHistoryItemGroup): Map<string, ColorIdentifier> {
678696
const colorMap = new Map<string, ColorIdentifier>([
679697
[currentHistoryItemGroup.name, historyItemGroupLocal]
680698
]);
@@ -684,6 +702,9 @@ class SCMHistoryViewModel extends Disposable {
684702
if (currentHistoryItemGroup.base) {
685703
colorMap.set(currentHistoryItemGroup.base.name, historyItemGroupBase);
686704
}
705+
if (this._historyItemGroupFilter.get() === 'all') {
706+
colorMap.set('*', '');
707+
}
687708

688709
return colorMap;
689710
}

0 commit comments

Comments
 (0)