@@ -116,5 +116,40 @@ namespace ts.projectSystem {
116
116
renameLocation : undefined ,
117
117
} ) ;
118
118
} ) ;
119
+
120
+ it ( "handles canonicalization of tsconfig path" , ( ) => {
121
+ const aTs : File = { path : "/Foo/a.ts" , content : "const x = 0;" } ;
122
+ const tsconfig : File = { path : "/Foo/tsconfig.json" , content : '{ "files": ["./a.ts"] }' } ;
123
+ const session = createSession ( createServerHost ( [ aTs , tsconfig ] ) ) ;
124
+ openFilesForSession ( [ aTs ] , session ) ;
125
+
126
+ const result = executeSessionRequest < protocol . GetEditsForRefactorRequest , protocol . GetEditsForRefactorResponse > ( session , protocol . CommandTypes . GetEditsForRefactor , {
127
+ file : aTs . path ,
128
+ startLine : 1 ,
129
+ startOffset : 1 ,
130
+ endLine : 2 ,
131
+ endOffset : aTs . content . length ,
132
+ refactor : "Move to a new file" ,
133
+ action : "Move to a new file" ,
134
+ } ) ;
135
+ assert . deepEqual < protocol . RefactorEditInfo | undefined > ( result , {
136
+ edits : [
137
+ {
138
+ fileName : aTs . path ,
139
+ textChanges : [ { start : { line : 1 , offset : 1 } , end : { line : 1 , offset : aTs . content . length + 1 } , newText : "" } ] ,
140
+ } ,
141
+ {
142
+ fileName : tsconfig . path ,
143
+ textChanges : [ { start : { line : 1 , offset : 21 } , end : { line : 1 , offset : 21 } , newText : ', "./x.ts"' } ] ,
144
+ } ,
145
+ {
146
+ fileName : "/Foo/x.ts" ,
147
+ textChanges : [ { start : { line : 0 , offset : 0 } , end : { line : 0 , offset : 0 } , newText : "const x = 0;\n" } ] ,
148
+ } ,
149
+ ] ,
150
+ renameFilename : undefined ,
151
+ renameLocation : undefined ,
152
+ } ) ;
153
+ } ) ;
119
154
} ) ;
120
155
}
0 commit comments