@@ -141,7 +141,7 @@ class App extends React.Component {
141141 contributors : undefined ,
142142 } , {
143143 name : `code.${ ext } ` ,
144- content : language ? language . skeleton : '' , // TODO: put import statements as default
144+ content : language ? language . skeleton : '' ,
145145 contributors : undefined ,
146146 } ] ,
147147 } ) ;
@@ -174,6 +174,7 @@ class App extends React.Component {
174174 const { files } = this . props . current ;
175175 if ( editorTabIndex === files . length ) this . handleAddFile ( ) ;
176176 this . setState ( { editorTabIndex } ) ;
177+ this . props . shouldBuild ( ) ;
177178 }
178179
179180 handleAddFile ( ) {
@@ -194,15 +195,11 @@ class App extends React.Component {
194195 this . props . renameFile ( editorTabIndex , value ) ;
195196 }
196197
197- handleDeleteFile ( file ) {
198- const { files } = this . props . current ;
198+ handleDeleteFile ( ) {
199199 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 ) ;
206203 }
207204
208205 toggleNavigatorOpened ( navigatorOpened = ! this . state . navigatorOpened ) {
@@ -230,13 +227,13 @@ class App extends React.Component {
230227 const { titles, files } = this . props . current ;
231228
232229 const gistSaved = this . isGistSaved ( ) ;
233-
234230 const description = this . getDescription ( ) ;
231+ const file = files [ editorTabIndex ] ;
235232
236233 const editorTitles = files . map ( file => file . name ) ;
237- if ( files [ editorTabIndex ] ) {
234+ if ( file ) {
238235 editorTitles [ editorTabIndex ] = (
239- < AutosizeInput className = { styles . input_title } value = { files [ editorTabIndex ] . name }
236+ < AutosizeInput className = { styles . input_title } value = { file . name }
240237 onClick = { e => e . stopPropagation ( ) } onChange = { e => this . handleRenameFile ( e ) } />
241238 ) ;
242239 }
@@ -253,20 +250,15 @@ class App extends React.Component {
253250 < Header className = { styles . header } onClickTitleBar = { ( ) => this . toggleNavigatorOpened ( ) }
254251 navigatorOpened = { navigatorOpened } loadScratchPapers = { ( ) => this . loadScratchPapers ( ) }
255252 loadAlgorithm = { params => this . loadAlgorithm ( params ) } gistSaved = { gistSaved }
256- file = { files [ editorTabIndex ] } />
253+ file = { file } />
257254 < ResizableContainer className = { styles . workspace } horizontal weights = { workspaceWeights }
258255 visibles = { [ navigatorOpened , true , true ] }
259256 onChangeWeights = { weights => this . handleChangeWorkspaceWeights ( weights ) } >
260257 < Navigator loadAlgorithm = { params => this . loadAlgorithm ( params ) } />
261258 < VisualizationViewer className = { styles . visualization_viewer } />
262259 < TabContainer className = { styles . editor_tab_container } titles = { editorTitles } tabIndex = { editorTabIndex }
263260 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 ( ) } />
270262 </ TabContainer >
271263 </ ResizableContainer >
272264 < ToastContainer className = { styles . toast_container } />
0 commit comments