summaryrefslogtreecommitdiffstats
path: root/mode-tree.c
diff options
context:
space:
mode:
authornicm <nicm>2017-08-27 09:08:36 +0000
committernicm <nicm>2017-08-27 09:08:36 +0000
commitfccfc4e4bed37b42c80797178621fe0d28c2f33b (patch)
tree499f2f542523c12b76f8c20efdb9a36eb3ec92c4 /mode-tree.c
parent25cf126de8abe607d2b0e63815bc1db4fd313173 (diff)
Do not allow the current line of screen when the preview is toggled,
from Thomas Adam.
Diffstat (limited to 'mode-tree.c')
-rw-r--r--mode-tree.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/mode-tree.c b/mode-tree.c
index 4e11a3b4..fc31592a 100644
--- a/mode-tree.c
+++ b/mode-tree.c
@@ -870,6 +870,15 @@ mode_tree_key(struct mode_tree_data *mtd, struct client *c, key_code *key,
case 'v':
mtd->preview = !mtd->preview;
mode_tree_build(mtd);
+
+ /*
+ * If the current line would now be off screen now the preview
+ * is on, reset the the offset to the last visible line.
+ */
+ if (mtd->preview && mtd->current > mtd->height - 1) {
+ mtd->offset = mtd->current - mtd->height;
+ mtd->current--;
+ }
break;
}
return (0);