Skip to content

Commit f0a0408

Browse files
committed
Adds search results to minimap tooltips
1 parent 35a3618 commit f0a0408

File tree

4 files changed

+64
-43
lines changed

4 files changed

+64
-43
lines changed

src/webviews/apps/plus/graph/GraphWrapper.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,9 @@ export function GraphWrapper({
603603

604604
result = searchResultsByDay.get(day);
605605
if (result == null) {
606-
searchResultsByDay.set(day, { type: 'search-result', sha: sha });
606+
searchResultsByDay.set(day, { type: 'search-result', sha: sha, count: 1 });
607+
} else {
608+
result.count++;
607609
}
608610
}
609611
}

src/webviews/apps/plus/graph/graph.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
--color-graph-minimap-tip-headBorder: var(--color-graph-scroll-marker-head);
6565
--color-graph-minimap-tip-headForeground: var(--vscode-editor-foreground, var(--vscode-foreground));
6666

67+
--color-graph-minimap-tip-highlightBackground: var(--color-graph-scroll-marker-highlights);
68+
--color-graph-minimap-tip-highlightBorder: var(--color-graph-scroll-marker-highlights);
69+
--color-graph-minimap-tip-highlightForeground: var(--vscode-editor-foreground, var(--vscode-foreground));
70+
6771
--color-graph-minimap-tip-branchBackground: var(--color-graph-scroll-marker-local-branches);
6872
--color-graph-minimap-tip-branchBorder: var(--color-graph-scroll-marker-local-branches);
6973
--color-graph-minimap-tip-branchForeground: var(--vscode-editor-foreground, var(--vscode-foreground));

src/webviews/apps/plus/graph/graph.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,22 +411,11 @@ export class GraphApp extends App<State> {
411411
);
412412

413413
c = Color.fromCssVariable('--vscode-editor-foreground', e.computedStyle);
414-
rootStyle.setProperty(
415-
'--color-graph-minimap-tip-branchForeground',
416-
c.isLighter() ? c.luminance(0.01).toString() : c.luminance(0.99).toString(),
417-
);
418-
419-
c = Color.fromCssVariable('--vscode-editor-foreground', e.computedStyle);
420-
rootStyle.setProperty(
421-
'--color-graph-minimap-tip-headForeground',
422-
c.isLighter() ? c.luminance(0.01).toString() : c.luminance(0.99).toString(),
423-
);
424-
425-
c = Color.fromCssVariable('--vscode-editor-foreground', e.computedStyle);
426-
rootStyle.setProperty(
427-
'--color-graph-minimap-tip-upstreamForeground',
428-
c.isLighter() ? c.luminance(0.01).toString() : c.luminance(0.99).toString(),
429-
);
414+
const tipForeground = c.isLighter() ? c.luminance(0.01).toString() : c.luminance(0.99).toString();
415+
rootStyle.setProperty('--color-graph-minimap-tip-headForeground', tipForeground);
416+
rootStyle.setProperty('--color-graph-minimap-tip-upstreamForeground', tipForeground);
417+
rootStyle.setProperty('--color-graph-minimap-tip-highlightForeground', tipForeground);
418+
rootStyle.setProperty('--color-graph-minimap-tip-branchForeground', tipForeground);
430419
}
431420

432421
const branchStatusLuminance = themeLuminance(e.isLightTheme ? 0.72 : 0.064);

src/webviews/apps/plus/graph/minimap/minimap.ts

Lines changed: 52 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export type GraphMinimapMarker = BranchMarker | RemoteMarker | StashMarker | Tag
3636
export interface GraphMinimapSearchResultMarker {
3737
type: 'search-result';
3838
sha: string;
39+
count: number;
3940
}
4041

4142
export interface GraphMinimapStats {
@@ -355,6 +356,24 @@ const styles = css`
355356
margin: 0.5rem 0;
356357
}
357358
359+
.bb-tooltip .results {
360+
display: flex;
361+
font-size: 12px;
362+
gap: 0.5rem;
363+
flex-direction: row;
364+
flex-wrap: wrap;
365+
margin: 0.5rem 0;
366+
max-width: fit-content;
367+
}
368+
369+
.bb-tooltip .results .result {
370+
border-radius: 3px;
371+
padding: 0 4px;
372+
background-color: var(--color-graph-minimap-tip-highlightBackground);
373+
border: 1px solid var(--color-graph-minimap-tip-highlightBorder);
374+
color: var(--color-graph-minimap-tip-highlightForeground);
375+
}
376+
358377
.bb-tooltip .refs {
359378
display: flex;
360379
font-size: 12px;
@@ -871,46 +890,53 @@ export class GraphMinimap extends FASTElement {
871890
contents: (data, _defaultTitleFormat, _defaultValueFormat, _color) => {
872891
const date = new Date(data[0].x);
873892

874-
const stat = this.data?.get(getDay(date));
875-
const markers = this.markers?.get(getDay(date));
893+
const day = getDay(date);
894+
const stat = this.data?.get(day);
895+
const markers = this.markers?.get(day);
896+
const results = this.searchResults?.get(day);
897+
876898
let groups;
877899
if (markers?.length) {
878900
groups = groupByMap(markers, m => m.type);
879901
}
880902

881903
const stashesCount = groups?.get('stash')?.length ?? 0;
882-
const showLinesChanged = this.dataType === 'lines';
904+
905+
let commits;
906+
let linesChanged;
907+
let resultsCount;
908+
if (stat?.commits) {
909+
commits = pluralize('commit', stat.commits, { format: c => formatNumeric(c) });
910+
if (results?.count) {
911+
resultsCount = pluralize('matching commit', results.count);
912+
}
913+
914+
if (this.dataType === 'lines') {
915+
linesChanged = `${pluralize('file', stat?.files ?? 0, {
916+
format: c => formatNumeric(c),
917+
zero: 'No',
918+
})}, ${pluralize(
919+
'line',
920+
(stat?.activity?.additions ?? 0) + (stat?.activity?.deletions ?? 0),
921+
{
922+
format: c => formatNumeric(c),
923+
zero: 'No',
924+
},
925+
)} changed`;
926+
}
927+
} else {
928+
commits = 'No commits';
929+
}
883930

884931
return /*html*/ `<div class="bb-tooltip">
885932
<div class="header">
886933
<span class="header--title">${formatDate(date, 'MMMM Do, YYYY')}</span>
887934
<span class="header--description">(${capitalize(fromNow(date))})</span>
888935
</div>
889936
<div class="changes">
890-
<span>${
891-
(stat?.commits ?? 0) === 0
892-
? 'No commits'
893-
: `${pluralize('commit', stat?.commits ?? 0, {
894-
format: c => formatNumeric(c),
895-
zero: 'No',
896-
})}${
897-
showLinesChanged
898-
? `, ${pluralize('file', stat?.files ?? 0, {
899-
format: c => formatNumeric(c),
900-
zero: 'No',
901-
})}, ${pluralize(
902-
'line',
903-
(stat?.activity?.additions ?? 0) +
904-
(stat?.activity?.deletions ?? 0),
905-
{
906-
format: c => formatNumeric(c),
907-
zero: 'No',
908-
},
909-
)} changed`
910-
: ''
911-
}`
912-
}</span>
937+
<span>${commits}${linesChanged ? `, ${linesChanged}` : ''}</span>
913938
</div>
939+
${resultsCount ? /*html*/ `<div class="results"><span class="result">${resultsCount}</span></div>` : ''}
914940
${
915941
groups != null
916942
? /*html*/ `

0 commit comments

Comments
 (0)