Stop requiring that the full range of a declaration fall within the

selection

Fixes #18546
This commit is contained in:
Andrew Casey
2017-09-18 19:12:06 -07:00
parent 21bbee4044
commit af49c60a2c
4 changed files with 27 additions and 6 deletions

View File

@@ -768,6 +768,11 @@ function parsePrimaryExpression(): any {
}
}|]
}
}`);
// Selection excludes leading trivia of declaration
testExtractMethod("extractMethod33",
`function F() {
[#|function G() { }|]
}`);
});

View File

@@ -1209,7 +1209,7 @@ namespace ts.refactor.extractMethod {
if (!declInFile) {
return undefined;
}
if (rangeContainsRange(enclosingTextRange, declInFile)) {
if (rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) {
// declaration is located in range to be extracted - do nothing
return undefined;
}