From 5b5939c33c522e0825681af3104398c8d620e70a Mon Sep 17 00:00:00 2001 From: Gerhard Tan Date: Sat, 17 Feb 2024 23:01:48 +0800 Subject: [PATCH] Prevent random names from removing range prefix --- ui/editproxy.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/editproxy.go b/ui/editproxy.go index 3e709296..22fa7eb6 100644 --- a/ui/editproxy.go +++ b/ui/editproxy.go @@ -125,7 +125,11 @@ func (pd *EditProxyDialog) View() Dialog { Children: []Widget{ LineEdit{AssignTo: &pd.nameView, Text: Bind("Name", consts.ValidateNonEmpty)}, PushButton{Text: i18n.SprintfLSpace("Random"), Image: loadResourceIcon(consts.IconRefresh, 16), OnClicked: func() { - pd.nameView.SetText(funk.RandomString(8)) + rs := funk.RandomString(8) + if strings.HasPrefix(pd.nameView.Text(), consts.RangePrefix) { + rs = consts.RangePrefix + rs + } + pd.nameView.SetText(rs) }}, }, },