Skip to content

Commit

Permalink
fix: add method regex to just run once. no lastIndex.
Browse files Browse the repository at this point in the history
  • Loading branch information
elonmallin committed Sep 11, 2017
1 parent 63891d4 commit 765c4fc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/phpunittest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export class TestRunner {

private readonly regex = {
method: /\s*public*\s+function\s+(test\w*)\s*\(/gi,
class: /class\s+(\w*)\s*{?/gi
class: /class\s+(\w*)\s*{?/gi,
methodOnce: /\s*public*\s+function\s+(test\w*)\s*\(/i
};

constructor(channel) {
Expand Down Expand Up @@ -58,7 +59,7 @@ export class TestRunner {
{
let line = editor.document.lineAt(range.start.line);
var wordOnCursor = editor.document.getText(range);
var isFunction = line.text.indexOf("function") != -1 && this.regex.method.test(line.text);
var isFunction = line.text.indexOf("function") != -1 && this.regex.methodOnce.test(line.text);
var isClass = line.text.indexOf("class") != -1;

if (isFunction && wordOnCursor != null)
Expand Down

0 comments on commit 765c4fc

Please sign in to comment.