File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1006,14 +1006,15 @@ namespace ts.server {
10061006
10071007 /**
10081008 * @param filename is absolute pathname
1009+ * @param fileContent is a known version of the file content that is more up to date
10091010 */
1010- openFile ( fileName : string , openedByClient : boolean ) {
1011+ openFile ( fileName : string , openedByClient : boolean , fileContent ?: string ) {
10111012 fileName = ts . normalizePath ( fileName ) ;
10121013 let info = ts . lookUp ( this . filenameToScriptInfo , fileName ) ;
10131014 if ( ! info ) {
10141015 let content : string ;
10151016 if ( this . host . fileExists ( fileName ) ) {
1016- content = this . host . readFile ( fileName ) ;
1017+ content = fileContent ? fileContent : this . host . readFile ( fileName ) ;
10171018 }
10181019 if ( ! content ) {
10191020 if ( openedByClient ) {
@@ -1060,10 +1061,11 @@ namespace ts.server {
10601061 /**
10611062 * Open file whose contents is managed by the client
10621063 * @param filename is absolute pathname
1064+ * @param fileContent is a known version of the file content that is more up to date
10631065 */
1064- openClientFile ( fileName : string ) {
1066+ openClientFile ( fileName : string , fileContent ?: string ) {
10651067 this . openOrUpdateConfiguredProjectForFile ( fileName ) ;
1066- const info = this . openFile ( fileName , true ) ;
1068+ const info = this . openFile ( fileName , true , fileContent ) ;
10671069 this . addOpenFile ( info ) ;
10681070 this . printProjects ( ) ;
10691071 return info ;
Original file line number Diff line number Diff line change @@ -513,6 +513,7 @@ declare namespace ts.server.protocol {
513513 * Information found in an "open" request.
514514 */
515515 export interface OpenRequestArgs extends FileRequestArgs {
516+ fileContent ?: string ;
516517 }
517518
518519 /**
Original file line number Diff line number Diff line change @@ -532,9 +532,13 @@ namespace ts.server {
532532 } ;
533533 }
534534
535- private openClientFile ( fileName : string ) {
535+ /**
536+ * @param fileName is the name of the file to be opened
537+ * @param fileContent is a version of the file content that is known to be more up to date
538+ */
539+ private openClientFile ( fileName : string , fileContent ?: string ) {
536540 const file = ts . normalizePath ( fileName ) ;
537- this . projectService . openClientFile ( file ) ;
541+ this . projectService . openClientFile ( file , fileContent ) ;
538542 }
539543
540544 private getQuickInfo ( line : number , offset : number , fileName : string ) : protocol . QuickInfoResponseBody {
@@ -968,7 +972,7 @@ namespace ts.server {
968972 } ,
969973 [ CommandNames . Open ] : ( request : protocol . Request ) => {
970974 const openArgs = < protocol . OpenRequestArgs > request . arguments ;
971- this . openClientFile ( openArgs . file ) ;
975+ this . openClientFile ( openArgs . file , openArgs . fileContent ) ;
972976 return { responseRequired : false } ;
973977 } ,
974978 [ CommandNames . Quickinfo ] : ( request : protocol . Request ) => {
You can’t perform that action at this time.
0 commit comments