Skip to content

Commit 52484f1

Browse files
committed
Don't show parentheses when results are not yet fetched
We missed a place where we needed to check if results are present before attempting to show them. Let's also add tests for this.
1 parent cba188b commit 52484f1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

extensions/ql-vscode/src/history-item-label-provider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,12 @@ export class HistoryItemLabelProvider {
7777
}
7878

7979
private getRemoteInterpolateReplacements(item: RemoteQueryHistoryItem): InterpolateReplacements {
80+
const resultCount = item.resultCount ? `(${pluralize(item.resultCount, 'result', 'results')})` : '';
8081
return {
8182
t: new Date(item.remoteQuery.executionStartTime).toLocaleString(env.language),
8283
q: `${item.remoteQuery.queryName} (${item.remoteQuery.language})`,
8384
d: this.buildRepoLabel(item),
84-
r: `(${pluralize(item.resultCount, 'result', 'results')})`,
85+
r: resultCount,
8586
s: item.status,
8687
f: path.basename(item.remoteQuery.queryFilePath),
8788
'%': '%'

extensions/ql-vscode/src/vscode-tests/no-workspace/history-item-label-provider.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ describe('HistoryItemLabelProvider', () => {
126126
expect(labelProvider.getShortLabel(fqi)).to.eq('query-name');
127127
});
128128

129+
describe('when results are present', () => {
130+
it('should display results if there are any', () => {
131+
const fqi = createMockRemoteQueryInfo({ resultCount: 16, repositoryCount: 2 });
132+
config.format = '%t %q %d %s %f %r %%';
133+
expect(labelProvider.getLabel(fqi)).to.eq(`${dateStr} query-name (javascript) 2 repositories in progress query-file.ql (16 results) %`);
134+
});
135+
});
136+
137+
describe('when results are not present', () => {
138+
it('should skip displaying them', () => {
139+
const fqi = createMockRemoteQueryInfo({ resultCount: 0, repositoryCount: 2 });
140+
config.format = '%t %q %d %s %f %r %%';
141+
expect(labelProvider.getLabel(fqi)).to.eq(`${dateStr} query-name (javascript) 2 repositories in progress query-file.ql %`);
142+
});
143+
});
144+
129145
function createMockRemoteQueryInfo({
130146
resultCount = 16,
131147
userSpecifiedLabel = undefined,

0 commit comments

Comments
 (0)