Mercurial > vim
comparison src/popupwin.c @ 16898:16fd1bb2e675 v8.1.1450
patch 8.1.1450: popup window positioning wrong when using padding or borders
commit https://github.com/vim/vim/commit/399d898ac1e6e587088b5bdd6e36eca4998bc1eb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 2 15:34:29 2019 +0200
patch 8.1.1450: popup window positioning wrong when using padding or borders
Problem: Popup window positioning wrong when using padding or borders.
Solution: Fix computing the position.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 02 Jun 2019 15:45:05 +0200 |
parents | 52fc577a087d |
children | 23645f9a5ce2 |
comparison
equal
deleted
inserted
replaced
16897:84c04459c23d | 16898:16fd1bb2e675 |
---|---|
380 int wrapped = 0; | 380 int wrapped = 0; |
381 int maxwidth; | 381 int maxwidth; |
382 int center_vert = FALSE; | 382 int center_vert = FALSE; |
383 int center_hor = FALSE; | 383 int center_hor = FALSE; |
384 int allow_adjust_left = !wp->w_popup_fixed; | 384 int allow_adjust_left = !wp->w_popup_fixed; |
385 int top_extra = wp->w_popup_border[0] + wp->w_popup_padding[0]; | |
386 int right_extra = wp->w_popup_border[1] + wp->w_popup_padding[1]; | |
387 int bot_extra = wp->w_popup_border[2] + wp->w_popup_padding[2]; | |
388 int left_extra = wp->w_popup_border[3] + wp->w_popup_padding[3]; | |
389 int extra_height = top_extra + bot_extra; | |
390 int extra_width = left_extra + right_extra; | |
385 | 391 |
386 wp->w_winrow = 0; | 392 wp->w_winrow = 0; |
387 wp->w_wincol = 0; | 393 wp->w_wincol = 0; |
388 if (wp->w_popup_pos == POPPOS_CENTER) | 394 if (wp->w_popup_pos == POPPOS_CENTER) |
389 { | 395 { |
472 else if (wp->w_popup_pos == POPPOS_BOTRIGHT | 478 else if (wp->w_popup_pos == POPPOS_BOTRIGHT |
473 || wp->w_popup_pos == POPPOS_TOPRIGHT) | 479 || wp->w_popup_pos == POPPOS_TOPRIGHT) |
474 { | 480 { |
475 // Right aligned: move to the right if needed. | 481 // Right aligned: move to the right if needed. |
476 // No truncation, because that would change the height. | 482 // No truncation, because that would change the height. |
477 if (wp->w_width < wp->w_wantcol) | 483 if (wp->w_width + extra_width < wp->w_wantcol) |
478 wp->w_wincol = wp->w_wantcol - wp->w_width; | 484 wp->w_wincol = wp->w_wantcol - (wp->w_width + extra_width); |
479 } | 485 } |
480 | 486 |
481 if (wp->w_height <= 1) | 487 if (wp->w_height <= 1) |
482 wp->w_height = wp->w_buffer->b_ml.ml_line_count + wrapped; | 488 wp->w_height = wp->w_buffer->b_ml.ml_line_count + wrapped; |
483 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight) | 489 if (wp->w_minheight > 0 && wp->w_height < wp->w_minheight) |
490 if (center_vert) | 496 if (center_vert) |
491 wp->w_winrow = (Rows - wp->w_height) / 2; | 497 wp->w_winrow = (Rows - wp->w_height) / 2; |
492 else if (wp->w_popup_pos == POPPOS_BOTRIGHT | 498 else if (wp->w_popup_pos == POPPOS_BOTRIGHT |
493 || wp->w_popup_pos == POPPOS_BOTLEFT) | 499 || wp->w_popup_pos == POPPOS_BOTLEFT) |
494 { | 500 { |
495 if (wp->w_height <= wp->w_wantline) | 501 if ((wp->w_height + extra_height) <= wp->w_wantline) |
496 // bottom aligned: may move down | 502 // bottom aligned: may move down |
497 wp->w_winrow = wp->w_wantline - wp->w_height; | 503 wp->w_winrow = wp->w_wantline - (wp->w_height + extra_height); |
498 else | 504 else |
499 // not enough space, make top aligned | 505 // not enough space, make top aligned |
500 wp->w_winrow = wp->w_wantline + 1; | 506 wp->w_winrow = wp->w_wantline + 1; |
501 } | 507 } |
502 | 508 |