@@ -201,9 +201,9 @@ namespace ts.refactor.extractSymbol {
201201
202202 // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span.
203203 // This may fail (e.g. you select two statements in the root of a source file)
204- let start = getParentNodeInSpan ( getTokenAtPosition ( sourceFile , span . start , /*includeJsDocComment*/ false ) , sourceFile , span ) ;
204+ const start = getParentNodeInSpan ( getTokenAtPosition ( sourceFile , span . start , /*includeJsDocComment*/ false ) , sourceFile , span ) ;
205205 // Do the same for the ending position
206- let end = getParentNodeInSpan ( findTokenOnLeftOfPosition ( sourceFile , textSpanEnd ( span ) ) , sourceFile , span ) ;
206+ const end = getParentNodeInSpan ( findTokenOnLeftOfPosition ( sourceFile , textSpanEnd ( span ) ) , sourceFile , span ) ;
207207
208208 const declarations : Symbol [ ] = [ ] ;
209209
@@ -217,31 +217,10 @@ namespace ts.refactor.extractSymbol {
217217 }
218218
219219 if ( start . parent !== end . parent ) {
220- // handle cases like 1 + [2 + 3] + 4
221- // user selection is marked with [].
222- // in this case 2 + 3 does not belong to the same tree node
223- // instead the shape of the tree looks like this:
224- // +
225- // / \
226- // + 4
227- // / \
228- // + 3
229- // / \
230- // 1 2
231- // in this case there is no such one node that covers ends of selection and is located inside the selection
232- // to handle this we check if both start and end of the selection belong to some binary operation
233- // and start node is parented by the parent of the end node
234- // if this is the case - expand the selection to the entire parent of end node (in this case it will be [1 + 2 + 3] + 4)
235- const startParent = skipParentheses ( start . parent ) ;
236- const endParent = skipParentheses ( end . parent ) ;
237- if ( isBinaryExpression ( startParent ) && isBinaryExpression ( endParent ) && isNodeDescendantOf ( startParent , endParent ) ) {
238- start = end = endParent ;
239- }
240- else {
241- // start and end nodes belong to different subtrees
242- return { errors : [ createFileDiagnostic ( sourceFile , span . start , length , Messages . CannotExtractRange ) ] } ;
243- }
220+ // start and end nodes belong to different subtrees
221+ return { errors : [ createFileDiagnostic ( sourceFile , span . start , length , Messages . CannotExtractRange ) ] } ;
244222 }
223+
245224 if ( start !== end ) {
246225 // start and end should be statements and parent should be either block or a source file
247226 if ( ! isBlockLike ( start . parent ) ) {
0 commit comments