From 4fec4cde0910d81f1cf1e3a81c6c4192fdf1f612 Mon Sep 17 00:00:00 2001 From: Hannes De Valkeneer Date: Wed, 1 Jan 2020 11:19:01 +0100 Subject: [PATCH] fix: make test fn regex non greedy Fix #10 --- src/RustCodeLensProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RustCodeLensProvider.ts b/src/RustCodeLensProvider.ts index f789f00..d091c36 100644 --- a/src/RustCodeLensProvider.ts +++ b/src/RustCodeLensProvider.ts @@ -44,7 +44,7 @@ export class RustCodeLensProvider implements CodeLensProvider { private testMethodLenses(doc: TextDocument) { const text = doc.getText(); const reTest = /#\[test\]/g; - const reFnTest = /fn\s+(.+)\s*\(\s*\)/g; + const reFnTest = /fn\s+(.+?)\s*\(\s*\)/g; let lenses: CodeLens[] = []; while (reTest.exec(text) !== null) { reFnTest.lastIndex = reTest.lastIndex;