Skip to content

Commit 65b49e3

Browse files
committed
fix(preview): handle renamed new file
1 parent f909ac6 commit 65b49e3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/runtime/utils/files.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ export const mergeDraft = (dbFiles: PreviewFile[] = [], draftAdditions: DraftFil
99

1010
// Merge darft additions
1111
for (const addition of additions) {
12+
// File is new
13+
if (addition.new) {
14+
mergedFiles.push({ path: addition.path, parsed: addition.parsed })
15+
}
1216
// File has been renamed
13-
if (addition.oldPath) {
17+
else if (addition.oldPath) {
1418
// Remove old file from deletions (only display renamed one)
1519
deletions.splice(deletions.findIndex(d => d.path === addition.oldPath), 1)
1620

@@ -39,10 +43,7 @@ export const mergeDraft = (dbFiles: PreviewFile[] = [], draftAdditions: DraftFil
3943
}
4044
// File has been added
4145
}
42-
else if (addition.new) {
43-
mergedFiles.push({ path: addition.path, parsed: addition.parsed })
44-
// File has been modified
45-
}
46+
// File has been modified
4647
else {
4748
const file = mergedFiles.find(f => f.path === addition.path)
4849
if (file) {

0 commit comments

Comments
 (0)