Skip to content

Commit 4f55810

Browse files
authored
fix: filename index auto-increment (vuejs#133)
1 parent a945563 commit 4f55810

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/editor/FileSelector.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ function startAddFile() {
3232
3333
while (true) {
3434
let hasConflict = false
35-
for (const file in store.state.files) {
36-
if (file === name) {
35+
for (const filename in store.state.files) {
36+
if (stripSrcPrefix(filename) === name) {
3737
hasConflict = true
3838
name = `Comp${++i}.vue`
3939
break

src/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export class ReplStore implements Store {
310310
const exported: Record<string, string> = {}
311311
for (const filename in this.state.files) {
312312
const normalized =
313-
filename === importMapFile ? filename : filename.replace(/^src\//, '')
313+
filename === importMapFile ? filename : stripSrcPrefix(filename)
314314
exported[normalized] = this.state.files[filename].code
315315
}
316316
return exported

0 commit comments

Comments
 (0)