@@ -992,14 +992,15 @@ namespace ts.server {
992992
993993 /**
994994 * @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
995996 */
996- openFile ( fileName : string , openedByClient : boolean ) {
997+ openFile ( fileName : string , openedByClient : boolean , fileContent ?: string ) {
997998 fileName = ts . normalizePath ( fileName ) ;
998- var info = ts . lookUp ( this . filenameToScriptInfo , fileName ) ;
999+ let info = ts . lookUp ( this . filenameToScriptInfo , fileName ) ;
9991000 if ( ! info ) {
1000- var content : string ;
1001+ let content : string ;
10011002 if ( this . host . fileExists ( fileName ) ) {
1002- content = this . host . readFile ( fileName ) ;
1003+ content = fileContent || this . host . readFile ( fileName ) ;
10031004 }
10041005 if ( ! content ) {
10051006 if ( openedByClient ) {
@@ -1017,6 +1018,9 @@ namespace ts.server {
10171018 }
10181019 }
10191020 if ( info ) {
1021+ if ( fileContent ) {
1022+ info . svc . reload ( fileContent ) ;
1023+ }
10201024 if ( openedByClient ) {
10211025 info . isOpen = true ;
10221026 }
@@ -1047,10 +1051,11 @@ namespace ts.server {
10471051 /**
10481052 * Open file whose contents is managed by the client
10491053 * @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
10501055 */
1051- openClientFile ( fileName : string ) {
1056+ openClientFile ( fileName : string , fileContent ?: string ) {
10521057 this . openOrUpdateConfiguredProjectForFile ( fileName ) ;
1053- var info = this . openFile ( fileName , true ) ;
1058+ const info = this . openFile ( fileName , true , fileContent ) ;
10541059 this . addOpenFile ( info ) ;
10551060 this . printProjects ( ) ;
10561061 return info ;
0 commit comments