@@ -14,7 +14,7 @@ namespace ts.refactor.extractMethod {
1414
1515 /** Compute the associated code actions */
1616 function getAvailableActions ( context : RefactorContext ) : ApplicableRefactorInfo [ ] | undefined {
17- const rangeToExtract = getRangeToExtract ( context . file , { start : context . startPosition , length : context . endPosition - context . startPosition } ) ;
17+ const rangeToExtract = getRangeToExtract ( context . file , { start : context . startPosition , length : getRefactorContextLength ( context ) } ) ;
1818
1919 const targetRange : TargetRange = rangeToExtract . targetRange ;
2020 if ( targetRange === undefined ) {
@@ -66,8 +66,7 @@ namespace ts.refactor.extractMethod {
6666 }
6767
6868 function getEditsForAction ( context : RefactorContext , actionName : string ) : RefactorEditInfo | undefined {
69- const length = context . endPosition === undefined ? 0 : context . endPosition - context . startPosition ;
70- const rangeToExtract = getRangeToExtract ( context . file , { start : context . startPosition , length } ) ;
69+ const rangeToExtract = getRangeToExtract ( context . file , { start : context . startPosition , length : getRefactorContextLength ( context ) } ) ;
7170 const targetRange : TargetRange = rangeToExtract . targetRange ;
7271
7372 const parsedIndexMatch = / ^ s c o p e _ ( \d + ) $ / . exec ( actionName ) ;
@@ -148,7 +147,7 @@ namespace ts.refactor.extractMethod {
148147 */
149148 // exported only for tests
150149 export function getRangeToExtract ( sourceFile : SourceFile , span : TextSpan ) : RangeToExtract {
151- const length = span . length || 0 ;
150+ const { length } = span ;
152151
153152 if ( length === 0 ) {
154153 return { errors : [ createFileDiagnostic ( sourceFile , span . start , length , Messages . StatementOrExpressionExpected ) ] } ;
0 commit comments