Do not use subtraction for comparators, this doesn't really matter for

IDs but it breaks key sorting. GitHub issue 5646 from Alexandre Fiori.
This commit is contained in:
nicm
2026-09-28 10:42:01 +00:00
committed by tmux update bot
parent a16e62849d
commit db3950ed07
3 changed files with 50 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: window.c,v 1.382 2026/09/28 10:25:43 nicm Exp $ */
/* $OpenBSD: window.c,v 1.383 2026/09/28 10:42:01 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -94,7 +94,11 @@ struct window_pane_prompt {
int
window_cmp(struct window *w1, struct window *w2)
{
return (w1->id - w2->id);
if (w1->id < w2->id)
return (-1);
if (w1->id > w2->id)
return (1);
return (0);
}
static void
@@ -201,7 +205,11 @@ winlink_cmp(struct winlink *wl1, struct winlink *wl2)
int
window_pane_cmp(struct window_pane *wp1, struct window_pane *wp2)
{
return (wp1->id - wp2->id);
if (wp1->id < wp2->id)
return (-1);
if (wp1->id > wp2->id)
return (1);
return (0);
}
struct winlink *