mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Keep the width when duplicating database table view field https://github.com/siyuan-note/siyuan/issues/11552
This commit is contained in:
parent
f1993e13e3
commit
68585e21e3
5 changed files with 69 additions and 19 deletions
|
|
@ -18,7 +18,9 @@ package util
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -32,6 +34,20 @@ func init() {
|
|||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
func GetDuplicateName(master string) (ret string) {
|
||||
ret = master + " (1)"
|
||||
r := regexp.MustCompile("^(.*) \\((\\d+)\\)$")
|
||||
m := r.FindStringSubmatch(master)
|
||||
if nil == m || 3 > len(m) {
|
||||
return
|
||||
}
|
||||
|
||||
num, _ := strconv.Atoi(m[2])
|
||||
num++
|
||||
ret = fmt.Sprintf("%s (%d)", m[1], num)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
letter = []rune("abcdefghijklmnopqrstuvwxyz0123456789")
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue