@@ -992,14 +992,15 @@ namespace ts.server {
992
992
993
993
/**
994
994
* @param filename is absolute pathname
995
+ * @param fileContent is a known version of the file content that is more up to date than the one on disk
995
996
*/
996
- openFile ( fileName : string , openedByClient : boolean ) {
997
+ openFile ( fileName : string , openedByClient : boolean , fileContent ?: string ) {
997
998
fileName = ts . normalizePath ( fileName ) ;
998
- var info = ts . lookUp ( this . filenameToScriptInfo , fileName ) ;
999
+ let info = ts . lookUp ( this . filenameToScriptInfo , fileName ) ;
999
1000
if ( ! info ) {
1000
- var content : string ;
1001
+ let content : string ;
1001
1002
if ( this . host . fileExists ( fileName ) ) {
1002
- content = this . host . readFile ( fileName ) ;
1003
+ content = fileContent || this . host . readFile ( fileName ) ;
1003
1004
}
1004
1005
if ( ! content ) {
1005
1006
if ( openedByClient ) {
@@ -1017,6 +1018,9 @@ namespace ts.server {
1017
1018
}
1018
1019
}
1019
1020
if ( info ) {
1021
+ if ( fileContent ) {
1022
+ info . svc . reload ( fileContent ) ;
1023
+ }
1020
1024
if ( openedByClient ) {
1021
1025
info . isOpen = true ;
1022
1026
}
@@ -1047,10 +1051,11 @@ namespace ts.server {
1047
1051
/**
1048
1052
* Open file whose contents is managed by the client
1049
1053
* @param filename is absolute pathname
1054
+ * @param fileContent is a known version of the file content that is more up to date than the one on disk
1050
1055
*/
1051
- openClientFile ( fileName : string ) {
1056
+ openClientFile ( fileName : string , fileContent ?: string ) {
1052
1057
this . openOrUpdateConfiguredProjectForFile ( fileName ) ;
1053
- var info = this . openFile ( fileName , true ) ;
1058
+ const info = this . openFile ( fileName , true , fileContent ) ;
1054
1059
this . addOpenFile ( info ) ;
1055
1060
this . printProjects ( ) ;
1056
1061
return info ;
0 commit comments