mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Merge pull request #3347 from Microsoft/irregularExpressionCompletion
Block completion when in the flags of a regular expression
This commit is contained in:
commit
4d8d1cc956
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let v = 100;
|
||||
/////a/./**/
|
||||
|
||||
goTo.marker();
|
||||
verify.not.memberListContains('v');
|
||||
verify.memberListContains('compile');
|
||||
@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let v = 100;
|
||||
////let x = /absidey//**/
|
||||
|
||||
// Should get nothing at the marker since it's
|
||||
// going to be considered part of the regex flags.
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListIsEmpty();
|
||||
@ -0,0 +1,11 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let v = 100;
|
||||
////let x = /absidey/
|
||||
/////**/
|
||||
|
||||
// Should not be blocked since there is a
|
||||
// newline separating us from the regex flags.
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains("v");
|
||||
@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let v = 100;
|
||||
////let x = /absidey/ /**/
|
||||
|
||||
// Should not be blocked since there is a
|
||||
// space separating us from the regex flags.
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListContains("v");
|
||||
@ -0,0 +1,10 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////let v = 100;
|
||||
////let x = /absidey/g/**/
|
||||
|
||||
// Should get nothing at the marker since it's
|
||||
// going to be considered part of the regex flags.
|
||||
|
||||
goTo.marker();
|
||||
verify.completionListIsEmpty()
|
||||
@ -3,5 +3,5 @@
|
||||
/////a/./**/
|
||||
|
||||
goTo.marker();
|
||||
//verify.not.memberListContains('alert');
|
||||
//verify.memberListContains('compile');
|
||||
verify.not.memberListContains('alert');
|
||||
verify.memberListContains('compile');
|
||||
Loading…
x
Reference in New Issue
Block a user