File tree Expand file tree Collapse file tree 2 files changed +64
-2
lines changed Expand file tree Collapse file tree 2 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -1005,9 +1005,26 @@ namespace ts.textChanges {
1005
1005
}
1006
1006
}
1007
1007
1008
- function getInsertionPositionAtSourceFileTop ( { text } : SourceFile ) : number {
1009
- const shebang = getShebang ( text ) ;
1008
+ function getInsertionPositionAtSourceFileTop ( sourceFile : SourceFile ) : number {
1009
+ let lastPrologue : PrologueDirective | undefined ;
1010
+ for ( const node of sourceFile . statements ) {
1011
+ if ( isPrologueDirective ( node ) ) {
1012
+ lastPrologue = node ;
1013
+ }
1014
+ else {
1015
+ break ;
1016
+ }
1017
+ }
1018
+
1010
1019
let position = 0 ;
1020
+ const text = sourceFile . text ;
1021
+ if ( lastPrologue ) {
1022
+ position = lastPrologue . end ;
1023
+ advancePastLineBreak ( ) ;
1024
+ return position ;
1025
+ }
1026
+
1027
+ const shebang = getShebang ( text ) ;
1011
1028
if ( shebang !== undefined ) {
1012
1029
position = shebang . length ;
1013
1030
advancePastLineBreak ( ) ;
Original file line number Diff line number Diff line change
1
+ /// <reference path='fourslash.ts' />
2
+
3
+ // @Filename : /a.ts
4
+ ////"use strict";
5
+ ////export class A { }
6
+
7
+ // @Filename : /b.ts
8
+ ////"use strict";
9
+ ////export class B extends A { }
10
+
11
+ // @Filename : /c.ts
12
+ /////*---------------------------------------------------------------------------------------------
13
+ //// * Copyright (c) Microsoft Corporation. All rights reserved.
14
+ //// * Licensed under the MIT License. See License.txt in the project root for license information.
15
+ //// *--------------------------------------------------------------------------------------------*/
16
+ ////"use strict";
17
+ ////export class B extends A { }
18
+
19
+ goTo . file ( "/b.ts" ) ;
20
+ verify . codeFixAll ( {
21
+ fixId : "fixMissingImport" ,
22
+ fixAllDescription : "Add all missing imports" ,
23
+ newFileContent :
24
+ `"use strict";
25
+
26
+ import { A } from "./a";
27
+
28
+ export class B extends A { }` ,
29
+ } ) ;
30
+
31
+ goTo . file ( "/c.ts" ) ;
32
+ verify . codeFixAll ( {
33
+ fixId : "fixMissingImport" ,
34
+ fixAllDescription : "Add all missing imports" ,
35
+ newFileContent :
36
+ `/*---------------------------------------------------------------------------------------------
37
+ * Copyright (c) Microsoft Corporation. All rights reserved.
38
+ * Licensed under the MIT License. See License.txt in the project root for license information.
39
+ *--------------------------------------------------------------------------------------------*/
40
+ "use strict";
41
+
42
+ import { A } from "./a";
43
+
44
+ export class B extends A { }` ,
45
+ } ) ;
You can’t perform that action at this time.
0 commit comments