Address code review: expand punctuation regex, add edge case tests

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/a55f8192-679d-45d7-b1ba-637b1df2730d

Co-authored-by: vijayupadya <41652029+vijayupadya@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-11 00:37:36 +00:00
committed by GitHub
parent 87e70edaa2
commit b8dd7e3ad7
2 changed files with 10 additions and 1 deletions

View File

@@ -35,5 +35,14 @@ suite('isLikelyNaturalLanguage', () => {
expect(isLikelyNaturalLanguage('const a = new Map()')).toBe(false);
expect(isLikelyNaturalLanguage('a === b ? c : d')).toBe(false);
expect(isLikelyNaturalLanguage('Array<string | number>')).toBe(false);
expect(isLikelyNaturalLanguage('foo.bar.baz method call')).toBe(false);
expect(isLikelyNaturalLanguage('a & b | c ^ d')).toBe(false);
expect(isLikelyNaturalLanguage('result = a + b / c')).toBe(false);
});
test('should handle edge cases', () => {
expect(isLikelyNaturalLanguage('')).toBe(false);
expect(isLikelyNaturalLanguage(' ')).toBe(false);
expect(isLikelyNaturalLanguage(' a ')).toBe(false);
});
});

View File

@@ -131,7 +131,7 @@ export function isLikelyNaturalLanguage(text: string): boolean {
// Code expressions with many tokens typically contain punctuation like
// parentheses, brackets, operators, etc. that natural language lacks.
if (/[()[\]{}<>=:;@#]/.test(text)) {
if (/[()[\]{}<>=:;@#.&|*+/%^~]/.test(text)) {
return false;
}