mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 00:51:26 +08:00
* fix: #438 to sort files in folder * Change to use localeCompare as per review
This commit is contained in:
parent
230c90c920
commit
68be52a87d
1
.github/CHANGELOG.md
vendored
1
.github/CHANGELOG.md
vendored
@ -141,6 +141,7 @@ foo<section>bar</section>zar
|
||||
- Mark Text didn't remove highlight when I delete the markdown symbol like * or `. (#893)
|
||||
- After delete ``` at the beginning to paragraph by backspace, then type other text foo, the color will be strange, if you type 1. bar. error happened. (#892)
|
||||
- Fix highlight error in code block (#545 #890)
|
||||
- Fix files sorting in folder (#438)
|
||||
|
||||
### 0.13.65
|
||||
|
||||
|
@ -28,7 +28,9 @@ const getters = {
|
||||
}
|
||||
|
||||
if (state.projectTree) travel(state.projectTree)
|
||||
return files.sort()
|
||||
files.sort((f1, f2) => f1.name.localeCompare(f2.name))
|
||||
|
||||
return files
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,15 @@ export const addFile = (tree, file) => {
|
||||
// Add file to related directory
|
||||
if (!currentFolder.files.find(f => f.name === name)) {
|
||||
file.id = getUniqueId()
|
||||
currentFolder.files.push(file)
|
||||
|
||||
const idx = currentFolder.files.findIndex(f => {
|
||||
return f.name.localeCompare(name) > 0
|
||||
})
|
||||
if (idx !== -1) {
|
||||
currentFolder.files.splice(idx, 0, file)
|
||||
} else {
|
||||
currentFolder.files.push(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user