From 3d872ba6f149bfce6de71f22e1530788bc5ac44f Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Sat, 14 Sep 2019 14:42:08 +0800 Subject: [PATCH 1/2] fix: Detect leetcode file by the comments --- src/codelens/CustomCodeLensProvider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codelens/CustomCodeLensProvider.ts b/src/codelens/CustomCodeLensProvider.ts index f201dbd7..d8bd59f0 100644 --- a/src/codelens/CustomCodeLensProvider.ts +++ b/src/codelens/CustomCodeLensProvider.ts @@ -22,8 +22,8 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider { return; } - const fileName: string = document.fileName.trim(); - const matchResult: RegExpMatchArray | null = fileName.match(/\d+\..*\.(.+)/); + const content: string = document.getText(); + const matchResult: RegExpMatchArray | null = content.match(/@lc app=.* id=.* lang=.*/g); if (!matchResult) { return undefined; } From e23fef666233db206ac3475a230d03ab0a7894ed Mon Sep 17 00:00:00 2001 From: Sheng Chen Date: Sat, 14 Sep 2019 14:45:20 +0800 Subject: [PATCH 2/2] Remove the global flag --- src/codelens/CustomCodeLensProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/codelens/CustomCodeLensProvider.ts b/src/codelens/CustomCodeLensProvider.ts index d8bd59f0..52deaf38 100644 --- a/src/codelens/CustomCodeLensProvider.ts +++ b/src/codelens/CustomCodeLensProvider.ts @@ -23,7 +23,7 @@ export class CustomCodeLensProvider implements vscode.CodeLensProvider { } const content: string = document.getText(); - const matchResult: RegExpMatchArray | null = content.match(/@lc app=.* id=.* lang=.*/g); + const matchResult: RegExpMatchArray | null = content.match(/@lc app=.* id=.* lang=.*/); if (!matchResult) { return undefined; }