@@ -9717,6 +9717,43 @@ export function Test2() {
9717
9717
} ) ;
9718
9718
} ) ;
9719
9719
9720
+ describe ( "tsserverProjectSystem refactors" , ( ) => {
9721
+ it ( "handles canonicalization of tsconfig path" , ( ) => {
9722
+ const aTs : File = { path : "/Foo/a.ts" , content : "const x = 0;" } ;
9723
+ const tsconfig : File = { path : "/Foo/tsconfig.json" , content : '{ "files": ["./a.ts"] }' } ;
9724
+ const session = createSession ( createServerHost ( [ aTs , tsconfig ] ) ) ;
9725
+ openFilesForSession ( [ aTs ] , session ) ;
9726
+
9727
+ const result = executeSessionRequest < protocol . GetEditsForRefactorRequest , protocol . GetEditsForRefactorResponse > ( session , protocol . CommandTypes . GetEditsForRefactor , {
9728
+ file : aTs . path ,
9729
+ startLine : 1 ,
9730
+ startOffset : 1 ,
9731
+ endLine : 2 ,
9732
+ endOffset : aTs . content . length ,
9733
+ refactor : "Move to a new file" ,
9734
+ action : "Move to a new file" ,
9735
+ } ) ;
9736
+ assert . deepEqual < protocol . RefactorEditInfo | undefined > ( result , {
9737
+ edits : [
9738
+ {
9739
+ fileName : aTs . path ,
9740
+ textChanges : [ { start : { line : 1 , offset : 1 } , end : { line : 1 , offset : aTs . content . length + 1 } , newText : "" } ] ,
9741
+ } ,
9742
+ {
9743
+ fileName : tsconfig . path ,
9744
+ textChanges : [ { start : { line : 1 , offset : 21 } , end : { line : 1 , offset : 21 } , newText : ', "./x.ts"' } ] ,
9745
+ } ,
9746
+ {
9747
+ fileName : "/Foo/x.ts" ,
9748
+ textChanges : [ { start : { line : 0 , offset : 0 } , end : { line : 0 , offset : 0 } , newText : "const x = 0;" } ] ,
9749
+ } ,
9750
+ ] ,
9751
+ renameFilename : undefined ,
9752
+ renameLocation : undefined ,
9753
+ } ) ;
9754
+ } ) ;
9755
+ } ) ;
9756
+
9720
9757
function makeReferenceItem ( file : File , isDefinition : boolean , text : string , lineText : string , options ?: SpanFromSubstringOptions ) : protocol . ReferencesResponseItem {
9721
9758
return {
9722
9759
...protocolFileSpanFromSubstring ( file , text , options ) ,
0 commit comments