mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 文档树支持 Ctrl+Click 和 Shift+↑/↓ 进行多选 https://github.com/siyuan-note/siyuan/issues/1359
This commit is contained in:
parent
f3bcdb1d39
commit
0378cf52d5
2 changed files with 32 additions and 30 deletions
|
|
@ -22,6 +22,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -173,3 +174,31 @@ func NormalizeEndpoint(endpoint string) string {
|
|||
}
|
||||
return endpoint
|
||||
}
|
||||
|
||||
func FilterFromPaths(fromPaths []string, toPath string) (retFromPaths []string) {
|
||||
fromPaths = append(fromPaths, toPath)
|
||||
retFromPaths = FilterSelfChildDocs(fromPaths)
|
||||
return
|
||||
}
|
||||
|
||||
func FilterSelfChildDocs(paths []string) (ret []string) {
|
||||
sort.Slice(paths, func(i, j int) bool { return len(paths[i]) < len(paths[j]) })
|
||||
|
||||
dirs := map[string]string{}
|
||||
for _, fromPath := range paths {
|
||||
dir := strings.TrimSuffix(fromPath, ".sy")
|
||||
existParent := false
|
||||
for d, _ := range dirs {
|
||||
if strings.HasPrefix(fromPath, d) {
|
||||
existParent = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if existParent {
|
||||
continue
|
||||
}
|
||||
dirs[dir] = fromPath
|
||||
ret = append(ret, fromPath)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue