From 472eab38e5ce5dfc8d164e3ac688dbea43de271e Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Tue, 24 Nov 2020 22:41:22 +0100 Subject: [PATCH] core: Prevent switching to start of visited buffers when jumping to next If you run /input jump_next_visited_buffer right after switching to a buffer, weechat changes to the first buffer in the visited buffers list. That is, it wraps around and goes to the buffer you visited the longest ago. This patch fixes that. The reason it happens is that when you switch to a buffer (normally, i.e. in another way than using jump_previously_visited_buffer/ jump_next_visited_buffer) gui_buffers_visited_index is set to -1 (in gui_buffer_visited_add). This makes gui_buffer_visited_get_index_next return 0 because it returns gui_buffers_visited_index + 1, which makes gui_input_jump_next_visited_buffer jump to the first buffer in the list of visited buffers. Fixes #1591 --- src/gui/gui-buffer.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index a4216d072..bac2c9fe6 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -4257,6 +4257,7 @@ int gui_buffer_visited_get_index_next () { if ((gui_buffers_visited_count < 2) + || (gui_buffers_visited_index < 0) || (gui_buffers_visited_index >= gui_buffers_visited_count - 1)) return -1;