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 @@ -700,6 +700,11 @@ function parsePrimaryExpression(): any {
700
700
}
701
701
}|]
702
702
}
703
+ }` ) ;
704
+ // Selection excludes leading trivia of declaration
705
+ testExtractMethod ( "extractMethod33" ,
706
+ `function F() {
707
+ [#|function G() { }|]
703
708
}` ) ;
704
709
} ) ;
705
710
Original file line number Diff line number Diff line change @@ -1070,7 +1070,7 @@ namespace ts.refactor.extractMethod {
1070
1070
if ( ! declInFile ) {
1071
1071
return undefined ;
1072
1072
}
1073
- if ( rangeContainsRange ( enclosingTextRange , declInFile ) ) {
1073
+ if ( rangeContainsStartEnd ( enclosingTextRange , declInFile . getStart ( ) , declInFile . end ) ) {
1074
1074
// declaration is located in range to be extracted - do nothing
1075
1075
return undefined ;
1076
1076
}
Original file line number Diff line number Diff line change
1
+ // ==ORIGINAL==
2
+ function F ( ) {
3
+ function G ( ) { }
4
+ }
5
+ // ==SCOPE::function 'F'==
6
+ function F ( ) {
7
+ /*RENAME*/ newFunction ( ) ;
8
+
9
+ function newFunction ( ) {
10
+ function G ( ) { }
11
+ }
12
+ }
13
+ // ==SCOPE::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 function into 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