Use test instead of match

This commit is contained in:
Matt Bierner 2019-10-18 15:35:42 -07:00
parent 035963b1f1
commit 2a46387970

View file

@ -81,13 +81,13 @@ class JsDocCompletionProvider implements vscode.CompletionItemProvider {
// or could be the opening of a comment // or could be the opening of a comment
const line = document.lineAt(position.line).text; const line = document.lineAt(position.line).text;
const prefix = line.slice(0, position.character); const prefix = line.slice(0, position.character);
if (prefix.match(/^\s*$|\/\*\*\s*$|^\s*\/\*\*+\s*$/) === null) { if (!/^\s*$|\/\*\*\s*$|^\s*\/\*\*+\s*$/.test(prefix)) {
return false; return false;
} }
// And everything after is possibly a closing comment or more whitespace // And everything after is possibly a closing comment or more whitespace
const suffix = line.slice(position.character); const suffix = line.slice(position.character);
return suffix.match(/^\s*\*+\//) !== null; return /^\s*(\*+\/)?\s*$/.test(suffix);
} }
} }