Merge pull request #18563 from amcasey/GH18546

Stop requiring that the full range of a declaration fall within the selection
This commit is contained in:
Andrew Casey
2017-09-19 10:47:16 -07:00
committed by GitHub
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

@@ -1205,7 +1205,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;
}