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