@@ -107,63 +107,67 @@ export class FileSystemProvider implements vscode.FileSystemProvider {
107
107
return ;
108
108
}
109
109
const api = new AtelierAPI ( uri ) ;
110
- return api
111
- . actionIndex ( [ fileName ] )
112
- . then ( ( data ) => data . result . content [ 0 ] )
113
- . then ( ( info ) => {
114
- if ( info . status === "" ) {
115
- /// file found, everything is Ok
116
- return ;
117
- }
118
- if ( options . create ) {
119
- if ( csp ) {
120
- return api . putDoc (
121
- fileName ,
122
- {
123
- content : [ content . toString ( "base64" ) ] ,
124
- enc : true ,
125
- mtime : Date . now ( ) ,
126
- } ,
127
- false
128
- ) ;
129
- }
130
- const fileExt = fileName . split ( "." ) . pop ( ) . toLowerCase ( ) ;
131
- if ( fileExt === "cls" ) {
132
- const className = fileName . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) ;
133
- return api . putDoc (
134
- fileName ,
135
- {
136
- content : [ `Class ${ className } {}` ] ,
137
- enc : false ,
138
- mtime : Date . now ( ) ,
139
- } ,
140
- false
141
- ) ;
142
- } else if ( [ "int" , "inc" , "mac" ] . includes ( fileExt ) ) {
143
- const api = new AtelierAPI ( uri ) ;
144
- const routineName = fileName . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) ;
145
- const routineType = `[ type = ${ fileExt } ]` ;
146
- return api . putDoc (
147
- fileName ,
148
- {
149
- content : [ `ROUTINE ${ routineName } ${ routineType } ` ] ,
150
- enc : false ,
151
- mtime : Date . now ( ) ,
152
- } ,
153
- false
154
- ) ;
155
- }
156
- throw new Error ( "Not implemented" ) ;
157
- }
158
- } )
159
- . then ( ( response ) => {
160
- if ( response && response . result . ext && response . result . ext [ 0 ] && response . result . ext [ 1 ] ) {
161
- fireOtherStudioAction ( OtherStudioAction . CreatedNewDocument , uri , response . result . ext [ 0 ] ) ;
162
- fireOtherStudioAction ( OtherStudioAction . FirstTimeDocumentSave , uri , response . result . ext [ 1 ] ) ;
163
- }
164
- this . _lookupAsFile ( uri ) . then ( ( entry ) => {
165
- this . _fireSoon ( { type : vscode . FileChangeType . Changed , uri } ) ;
166
- } ) ;
110
+ return this . _lookupAsFile ( uri )
111
+ . then ( ( file ) => ( file . data = content ) )
112
+ . then ( ( ) => {
113
+ api
114
+ . actionIndex ( [ fileName ] )
115
+ . then ( ( data ) => data . result . content [ 0 ] )
116
+ . then ( ( info ) => {
117
+ if ( info . status === "" ) {
118
+ /// file found, everything is Ok
119
+ return ;
120
+ }
121
+ if ( options . create ) {
122
+ if ( csp ) {
123
+ return api . putDoc (
124
+ fileName ,
125
+ {
126
+ content : [ content . toString ( "base64" ) ] ,
127
+ enc : true ,
128
+ mtime : Date . now ( ) ,
129
+ } ,
130
+ false
131
+ ) ;
132
+ }
133
+ const fileExt = fileName . split ( "." ) . pop ( ) . toLowerCase ( ) ;
134
+ if ( fileExt === "cls" ) {
135
+ const className = fileName . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) ;
136
+ return api . putDoc (
137
+ fileName ,
138
+ {
139
+ content : [ `Class ${ className } {}` ] ,
140
+ enc : false ,
141
+ mtime : Date . now ( ) ,
142
+ } ,
143
+ false
144
+ ) ;
145
+ } else if ( [ "int" , "inc" , "mac" ] . includes ( fileExt ) ) {
146
+ const api = new AtelierAPI ( uri ) ;
147
+ const routineName = fileName . split ( "." ) . slice ( 0 , - 1 ) . join ( "." ) ;
148
+ const routineType = `[ type = ${ fileExt } ]` ;
149
+ return api . putDoc (
150
+ fileName ,
151
+ {
152
+ content : [ `ROUTINE ${ routineName } ${ routineType } ` ] ,
153
+ enc : false ,
154
+ mtime : Date . now ( ) ,
155
+ } ,
156
+ false
157
+ ) ;
158
+ }
159
+ throw new Error ( "Not implemented" ) ;
160
+ }
161
+ } )
162
+ . then ( ( response ) => {
163
+ if ( response && response . result . ext && response . result . ext [ 0 ] && response . result . ext [ 1 ] ) {
164
+ fireOtherStudioAction ( OtherStudioAction . CreatedNewDocument , uri , response . result . ext [ 0 ] ) ;
165
+ fireOtherStudioAction ( OtherStudioAction . FirstTimeDocumentSave , uri , response . result . ext [ 1 ] ) ;
166
+ }
167
+ this . _lookupAsFile ( uri ) . then ( ( entry ) => {
168
+ this . _fireSoon ( { type : vscode . FileChangeType . Changed , uri } ) ;
169
+ } ) ;
170
+ } ) ;
167
171
} ) ;
168
172
}
169
173
0 commit comments