From 82325b0de33fbd23af8a27e221dc27e28a3fabe7 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 6 Oct 2024 09:30:22 +0000 Subject: [PATCH] Try to stay near the same line in modes if the current one is removed. --- usr.bin/tmux/mode-tree.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/usr.bin/tmux/mode-tree.c b/usr.bin/tmux/mode-tree.c index 0bd42b324f9..0a90515085d 100644 --- a/usr.bin/tmux/mode-tree.c +++ b/usr.bin/tmux/mode-tree.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mode-tree.c,v 1.70 2024/10/01 10:10:29 nicm Exp $ */ +/* $OpenBSD: mode-tree.c,v 1.71 2024/10/06 09:30:22 nicm Exp $ */ /* * Copyright (c) 2017 Nicholas Marriott @@ -356,8 +356,13 @@ mode_tree_set_current(struct mode_tree_data *mtd, uint64_t tag) mtd->offset = 0; return (1); } - mtd->current = 0; - mtd->offset = 0; + if (mtd->current >= mtd->line_size) { + mtd->current = mtd->line_size - 1; + if (mtd->current > mtd->height - 1) + mtd->offset = mtd->current - mtd->height + 1; + else + mtd->offset = 0; + } return (0); } -- 2.20.1