File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -768,6 +768,11 @@ function parsePrimaryExpression(): any {
768
768
}
769
769
}|]
770
770
}
771
+ }` ) ;
772
+ // Selection excludes leading trivia of declaration
773
+ testExtractMethod ( "extractMethod33" ,
774
+ `function F() {
775
+ [#|function G() { }|]
771
776
}` ) ;
772
777
} ) ;
773
778
Original file line number Diff line number Diff line change @@ -1209,7 +1209,7 @@ namespace ts.refactor.extractMethod {
1209
1209
if ( ! declInFile ) {
1210
1210
return undefined ;
1211
1211
}
1212
- if ( rangeContainsRange ( enclosingTextRange , declInFile ) ) {
1212
+ if ( rangeContainsStartEnd ( enclosingTextRange , declInFile . getStart ( ) , declInFile . end ) ) {
1213
1213
// declaration is located in range to be extracted - do nothing
1214
1214
return undefined ;
1215
1215
}
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ function F ( ) {
3
+ function G ( ) { }
4
+ }
5
+ // ==SCOPE::inner function in function 'F'==
6
+ function F ( ) {
7
+ /*RENAME*/ newFunction ( ) ;
8
+
9
+ function newFunction ( ) {
10
+ function G ( ) { }
11
+ }
12
+ }
13
+ // ==SCOPE::function in global scope==
14
+ function F ( ) {
15
+ /*RENAME*/ newFunction ( ) ;
16
+ }
17
+ function newFunction ( ) {
18
+ function G ( ) { }
19
+ }
Original file line number Diff line number Diff line change 1
1
/// <reference path='fourslash.ts' />
2
2
3
- // TODO: GH#18546
4
- // For now this tests that at least we don't crash.
5
-
6
3
////function f() {
7
4
//// /*start*/namespace N {}/*end*/
8
5
//// }
@@ -13,9 +10,9 @@ edit.applyRefactor({
13
10
actionName : "scope_1" ,
14
11
actionDescription : "Extract to function in global scope" ,
15
12
newContent : `function f() {
16
- /*RENAME*/newFunction(N );
13
+ /*RENAME*/newFunction();
17
14
}
18
- function newFunction(N: any ) {
15
+ function newFunction() {
19
16
namespace N { }
20
17
}
21
18
`
You can’t perform that action at this time.
0 commit comments