@@ -141,7 +141,7 @@ class App extends React.Component {
141
141
contributors : undefined ,
142
142
} , {
143
143
name : `code.${ ext } ` ,
144
- content : language ? language . skeleton : '' , // TODO: put import statements as default
144
+ content : language ? language . skeleton : '' ,
145
145
contributors : undefined ,
146
146
} ] ,
147
147
} ) ;
@@ -174,6 +174,7 @@ class App extends React.Component {
174
174
const { files } = this . props . current ;
175
175
if ( editorTabIndex === files . length ) this . handleAddFile ( ) ;
176
176
this . setState ( { editorTabIndex } ) ;
177
+ this . props . shouldBuild ( ) ;
177
178
}
178
179
179
180
handleAddFile ( ) {
@@ -194,15 +195,11 @@ class App extends React.Component {
194
195
this . props . renameFile ( editorTabIndex , value ) ;
195
196
}
196
197
197
- handleDeleteFile ( file ) {
198
- const { files } = this . props . current ;
198
+ handleDeleteFile ( ) {
199
199
const { editorTabIndex } = this . state ;
200
- if ( files . indexOf ( file ) < editorTabIndex ) {
201
- this . handleChangeEditorTabIndex ( editorTabIndex - 1 ) ;
202
- } else {
203
- this . handleChangeEditorTabIndex ( Math . min ( editorTabIndex , files . length - 2 ) ) ;
204
- }
205
- this . props . deleteFile ( file ) ;
200
+ const { files } = this . props . current ;
201
+ this . handleChangeEditorTabIndex ( Math . min ( editorTabIndex , files . length - 2 ) ) ;
202
+ this . props . deleteFile ( editorTabIndex ) ;
206
203
}
207
204
208
205
toggleNavigatorOpened ( navigatorOpened = ! this . state . navigatorOpened ) {
@@ -230,13 +227,13 @@ class App extends React.Component {
230
227
const { titles, files } = this . props . current ;
231
228
232
229
const gistSaved = this . isGistSaved ( ) ;
233
-
234
230
const description = this . getDescription ( ) ;
231
+ const file = files [ editorTabIndex ] ;
235
232
236
233
const editorTitles = files . map ( file => file . name ) ;
237
- if ( files [ editorTabIndex ] ) {
234
+ if ( file ) {
238
235
editorTitles [ editorTabIndex ] = (
239
- < AutosizeInput className = { styles . input_title } value = { files [ editorTabIndex ] . name }
236
+ < AutosizeInput className = { styles . input_title } value = { file . name }
240
237
onClick = { e => e . stopPropagation ( ) } onChange = { e => this . handleRenameFile ( e ) } />
241
238
) ;
242
239
}
@@ -253,20 +250,15 @@ class App extends React.Component {
253
250
< Header className = { styles . header } onClickTitleBar = { ( ) => this . toggleNavigatorOpened ( ) }
254
251
navigatorOpened = { navigatorOpened } loadScratchPapers = { ( ) => this . loadScratchPapers ( ) }
255
252
loadAlgorithm = { params => this . loadAlgorithm ( params ) } gistSaved = { gistSaved }
256
- file = { files [ editorTabIndex ] } />
253
+ file = { file } />
257
254
< ResizableContainer className = { styles . workspace } horizontal weights = { workspaceWeights }
258
255
visibles = { [ navigatorOpened , true , true ] }
259
256
onChangeWeights = { weights => this . handleChangeWorkspaceWeights ( weights ) } >
260
257
< Navigator loadAlgorithm = { params => this . loadAlgorithm ( params ) } />
261
258
< VisualizationViewer className = { styles . visualization_viewer } />
262
259
< TabContainer className = { styles . editor_tab_container } titles = { editorTitles } tabIndex = { editorTabIndex }
263
260
onChangeTabIndex = { tabIndex => this . handleChangeEditorTabIndex ( tabIndex ) } >
264
- {
265
- files . map ( ( file , i ) => ( // TODO: editor cursor should stay when moved to scratch paper
266
- < CodeEditor key = { [ ...titles , i ] . join ( '--' ) } file = { file }
267
- onDeleteFile = { file => this . handleDeleteFile ( file ) } />
268
- ) )
269
- }
261
+ < CodeEditor file = { file } onClickDelete = { ( ) => this . handleDeleteFile ( ) } />
270
262
</ TabContainer >
271
263
</ ResizableContainer >
272
264
< ToastContainer className = { styles . toast_container } />
0 commit comments