Skip to content

Commit 13b131c

Browse files
committed
Fix adding file
1 parent 144adbd commit 13b131c

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/frontend/components/App/index.jsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,11 @@ class App extends BaseComponent {
171171
handleAddFile() {
172172
const { ext } = this.props.env;
173173
const { files } = this.props.current;
174-
let name = `code.${ext}`;
175-
let count = 0;
176-
while (files.some(file => file.name === name)) name = `code-${++count}.${ext}`;
177174
const language = languages.find(language => language.ext === ext);
178-
this.props.addFile({
179-
name,
180-
content: language.skeleton,
181-
contributors: undefined,
182-
});
175+
const file = {...language.skeleton};
176+
let count = 0;
177+
while (files.some(existingFile => existingFile.name === file.name)) file.name = `code-${++count}.${ext}`;
178+
this.props.addFile(file);
183179
}
184180

185181
handleRenameFile(e) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy