From 9528d7470b52f25a47a74670d106dd84f709fb71 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. --- mode-tree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mode-tree.c b/mode-tree.c index ff12b54f..a63602c6 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -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); }