diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-05 17:38:04 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-05 17:38:04 +0200 |
commit | 96eb7acf242f3ea3bceb547c1190ce0882832314 (patch) | |
tree | d6384ce455a01a0799d531020d6f7a2532435651 /ui/listview.go | |
parent | ui: attach shortcuts to their windows (diff) | |
download | wireguard-windows-96eb7acf242f3ea3bceb547c1190ce0882832314.tar.xz wireguard-windows-96eb7acf242f3ea3bceb547c1190ce0882832314.zip |
ui: use natural sorting order
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | ui/listview.go | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/ui/listview.go b/ui/listview.go index c4f5186b..2e9ee3a7 100644 --- a/ui/listview.go +++ b/ui/listview.go @@ -6,8 +6,8 @@ package ui import ( + "golang.zx2c4.com/wireguard/windows/conf" "sort" - "strings" "sync/atomic" "github.com/lxn/walk" @@ -43,8 +43,7 @@ func (t *ListModel) Value(row, col int) interface{} { func (t *ListModel) Sort(col int, order walk.SortOrder) error { sort.SliceStable(t.tunnels, func(i, j int) bool { - //TODO: use real string comparison for sorting with proper tunnel order - return t.tunnels[i].Name < t.tunnels[j].Name + return conf.TunnelNameIsLess(t.tunnels[i].Name, t.tunnels[j].Name) }) return t.SorterBase.Sort(col, order) @@ -201,8 +200,7 @@ func (tv *ListView) Load(asyncUI bool) { firstTunnelName := "" for tunnel := range newTunnels { if !oldTunnels[tunnel] { - //TODO: use proper tunnel string sorting/comparison algorithm, as the other comments indicate too. - if len(firstTunnelName) == 0 || strings.Compare(firstTunnelName, tunnel.Name) > 0 { + if len(firstTunnelName) == 0 || !conf.TunnelNameIsLess(firstTunnelName, tunnel.Name) { firstTunnelName = tunnel.Name } tv.model.tunnels = append(tv.model.tunnels, tunnel) |