mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 21:36:50 -05:00
Merge pull request #3347 from Microsoft/irregularExpressionCompletion
Block completion when in the flags of a regular expression
This commit is contained in:
@@ -3130,16 +3130,20 @@ module ts {
|
||||
if (previousToken.kind === SyntaxKind.StringLiteral
|
||||
|| previousToken.kind === SyntaxKind.RegularExpressionLiteral
|
||||
|| isTemplateLiteralKind(previousToken.kind)) {
|
||||
// The position has to be either: 1. entirely within the token text, or
|
||||
// 2. at the end position of an unterminated token.
|
||||
let start = previousToken.getStart();
|
||||
let end = previousToken.getEnd();
|
||||
|
||||
// To be "in" one of these literals, the position has to be:
|
||||
// 1. entirely within the token text.
|
||||
// 2. at the end position of an unterminated token.
|
||||
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
|
||||
if (start < position && position < end) {
|
||||
return true;
|
||||
}
|
||||
else if (position === end) {
|
||||
return !!(<LiteralExpression>previousToken).isUnterminated;
|
||||
|
||||
if (position === end) {
|
||||
return !!(<LiteralExpression>previousToken).isUnterminated ||
|
||||
previousToken.kind === SyntaxKind.RegularExpressionLiteral;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user