提交 13b131cc 编写于 作者: J Jason Park

Fix adding file

上级 144adbd3
...@@ -171,15 +171,11 @@ class App extends BaseComponent { ...@@ -171,15 +171,11 @@ class App extends BaseComponent {
handleAddFile() { handleAddFile() {
const { ext } = this.props.env; const { ext } = this.props.env;
const { files } = this.props.current; const { files } = this.props.current;
let name = `code.${ext}`;
let count = 0;
while (files.some(file => file.name === name)) name = `code-${++count}.${ext}`;
const language = languages.find(language => language.ext === ext); const language = languages.find(language => language.ext === ext);
this.props.addFile({ const file = {...language.skeleton};
name, let count = 0;
content: language.skeleton, while (files.some(existingFile => existingFile.name === file.name)) file.name = `code-${++count}.${ext}`;
contributors: undefined, this.props.addFile(file);
});
} }
handleRenameFile(e) { handleRenameFile(e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册