Skip to content

Commit a88da59

Browse files
committed
support more prefixes
1 parent a871a19 commit a88da59

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,9 @@
625625
"default": [
626626
"//",
627627
"#",
628-
"--"
628+
"--",
629+
" * ",
630+
"///"
629631
],
630632
"description": "%githubIssues.createIssueCommentPrefixes.description%"
631633
},

src/test/issues/issueTodoProvider.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,58 @@ describe('IssueTodoProvider', function () {
188188

189189
vscode.workspace.getConfiguration = originalGetConfiguration; // restore
190190
});
191+
192+
it('prefix matrix detection', async function () {
193+
const mockContext = { subscriptions: [] } as any as vscode.ExtensionContext;
194+
const mockCopilotManager = { isAvailable: async () => true } as any;
195+
196+
const testCases: { testLine: string; expected: boolean; note?: string }[] = [
197+
{ testLine: ' // TODO implement feature', expected: true },
198+
{ testLine: '\t//TODO implement feature', expected: true },
199+
{ testLine: ' # TODO spaced hash', expected: true },
200+
{ testLine: '-- TODO dash dash', expected: true },
201+
{ testLine: ' * TODO docblock star', expected: true },
202+
{ testLine: '\t* TODO extra spaces after star', expected: true },
203+
{ testLine: '/// TODO rust style', expected: true },
204+
{ testLine: '///TODO rust tight', expected: true },
205+
{ testLine: 'let x = 0; // TODO not at line start so should not match', expected: false },
206+
{ testLine: ' *TODO (no space after star)', expected: false },
207+
{ testLine: ' * NotATrigger word', expected: false },
208+
{ testLine: '/* TODO inside block start should not (prefix not configured)', expected: false },
209+
{ testLine: 'random text TODO (no prefix)', expected: false },
210+
{ testLine: '#TODO tight hash', expected: true },
211+
];
212+
213+
const originalGetConfiguration = vscode.workspace.getConfiguration;
214+
vscode.workspace.getConfiguration = (section?: string) => {
215+
if (section === 'githubIssues') {
216+
return {
217+
get: (key: string, defaultValue?: any) => {
218+
if (key === 'createIssueTriggers') { return ['TODO']; }
219+
if (key === 'createIssueCommentPrefixes') { return ['//', '#', '--', ' * ', '///']; }
220+
return defaultValue;
221+
}
222+
} as any;
223+
}
224+
if (section === 'githubPullRequests.codingAgent') {
225+
return { get: () => true } as any;
226+
}
227+
return originalGetConfiguration(section);
228+
};
229+
230+
try {
231+
const provider = new IssueTodoProvider(mockContext, mockCopilotManager);
232+
for (const tc of testCases) {
233+
const document = {
234+
lineAt: (_line: number) => ({ text: tc.testLine }),
235+
lineCount: 1
236+
} as vscode.TextDocument;
237+
const codeLenses = await provider.provideCodeLenses(document, new vscode.CancellationTokenSource().token);
238+
const detected = codeLenses.length > 0;
239+
assert.strictEqual(detected, tc.expected, `Mismatch for line: "${tc.testLine}"`);
240+
}
241+
} finally {
242+
vscode.workspace.getConfiguration = originalGetConfiguration;
243+
}
244+
});
191245
});

0 commit comments

Comments
 (0)