diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-12-31 23:58:55 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-12-31 23:58:55 +0100 |
commit | d364298d758f93bc1b785ab64e8d05012725e218 (patch) | |
tree | 04257573c03d3e1ff56a61be78a920b02a923a7d /src/gui/gui-buffer.c | |
parent | 9835d530b9ea562917689f1d061aab9c765d3541 (diff) | |
download | weechat-d364298d758f93bc1b785ab64e8d05012725e218.zip |
core: fix unneeded shift of buffer numbers when a buffer with layout is created and merged
Diffstat (limited to 'src/gui/gui-buffer.c')
-rw-r--r-- | src/gui/gui-buffer.c | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 1080996aa..f03f7e2a8 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -379,9 +379,10 @@ gui_buffer_shift_numbers (struct t_gui_buffer *buffer) void gui_buffer_insert (struct t_gui_buffer *buffer) { - struct t_gui_buffer *pos_buffer, *ptr_buffer; + struct t_gui_buffer *pos_buffer, *ptr_buffer, *merge_buffer; int force_number; + merge_buffer = NULL; force_number = 0; pos_buffer = gui_buffer_find_pos (buffer); @@ -416,6 +417,23 @@ gui_buffer_insert (struct t_gui_buffer *buffer) } } + /* + * if position is found in list and that buffer is in layout and must be + * merged to another buffer (before/after), then force merge with buffer and + * add buffer to the end (to be sure no other buffer number will be shifted + * before the merge) + */ + if (pos_buffer + && (buffer->layout_number > 0) + && ((buffer->layout_number == pos_buffer->layout_number) + || (pos_buffer->prev_buffer + && (buffer->layout_number == (pos_buffer->prev_buffer)->layout_number)))) + { + merge_buffer = (buffer->layout_number == pos_buffer->layout_number) ? + pos_buffer : pos_buffer->prev_buffer; + pos_buffer = NULL; + } + if (pos_buffer) { /* add buffer into the list (before position found) */ @@ -468,18 +486,23 @@ gui_buffer_insert (struct t_gui_buffer *buffer) last_gui_buffer = buffer; } - /* merge buffer with previous or next, if they have layout number */ - if (buffer->layout_number > 0) + if (merge_buffer) + gui_buffer_merge (buffer, merge_buffer); + else { - if (buffer->prev_buffer - && (buffer->layout_number == (buffer->prev_buffer)->layout_number)) + /* merge buffer with previous or next, if they have layout number */ + if (buffer->layout_number > 0) { - gui_buffer_merge (buffer, buffer->prev_buffer); - } - else if ((buffer->next_buffer) - && (buffer->layout_number == (buffer->next_buffer)->layout_number)) - { - gui_buffer_merge (buffer->next_buffer, buffer); + if (buffer->prev_buffer + && (buffer->layout_number == (buffer->prev_buffer)->layout_number)) + { + gui_buffer_merge (buffer, buffer->prev_buffer); + } + else if ((buffer->next_buffer) + && (buffer->layout_number == (buffer->next_buffer)->layout_number)) + { + gui_buffer_merge (buffer->next_buffer, buffer); + } } } } |