aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorandrew-pa <andrew.pa@outlook.com>2021-06-10 20:07:52 -0700
committerSean Dewar <seandewar@users.noreply.github.com>2021-09-16 15:00:31 +0100
commit2132c063af3adf1d612359e0ed42c7cbd8b4290c (patch)
tree778b8b9ebdf8cec2d90c77eece08abdad94329c8 /src
parent132053c1d2bd101fb5d43b31e87073ba92c329d1 (diff)
downloadrneovim-2132c063af3adf1d612359e0ed42c7cbd8b4290c.tar.gz
rneovim-2132c063af3adf1d612359e0ed42c7cbd8b4290c.tar.bz2
rneovim-2132c063af3adf1d612359e0ed42c7cbd8b4290c.zip
backport: fix(windowing): positioning of relative floats
Fix relative floating windows so that they open in the correct position relative to each other. Also make sure that their positions are correct immediately after creation without a redraw.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/window.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 472a52e113..a64dee24a0 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -737,6 +737,37 @@ void win_config_float(win_T *wp, FloatConfig fconfig)
redraw_later(wp, NOT_VALID);
}
+ // compute initial position
+ if (wp->w_float_config.relative == kFloatRelativeWindow) {
+ int row = wp->w_float_config.row;
+ int col = wp->w_float_config.col;
+ Error dummy = ERROR_INIT;
+ win_T *parent = find_window_by_handle(wp->w_float_config.window, &dummy);
+ if (parent) {
+ row += parent->w_winrow;
+ col += parent->w_wincol;
+ ScreenGrid *grid = &parent->w_grid;
+ int row_off = 0, col_off = 0;
+ screen_adjust_grid(&grid, &row_off, &col_off);
+ row += row_off;
+ col += col_off;
+ }
+ api_clear_error(&dummy);
+ if (wp->w_float_config.bufpos.lnum >= 0) {
+ pos_T pos = { wp->w_float_config.bufpos.lnum + 1,
+ wp->w_float_config.bufpos.col, 0 };
+ int trow, tcol, tcolc, tcole;
+ textpos2screenpos(wp, &pos, &trow, &tcol, &tcolc, &tcole, true);
+ row += trow - 1;
+ col += tcol - 1;
+ }
+ wp->w_winrow = row;
+ wp->w_wincol = col;
+ } else {
+ wp->w_winrow = fconfig.row;
+ wp->w_wincol = fconfig.col;
+ }
+
// changing border style while keeping border only requires redrawing border
if (fconfig.border) {
wp->w_redr_border = true;
@@ -770,7 +801,6 @@ int win_fdccol_count(win_T *wp)
}
}
-
void ui_ext_win_position(win_T *wp)
{
if (!wp->w_floating) {
@@ -817,6 +847,8 @@ void ui_ext_win_position(win_T *wp)
int comp_row = (int)row - (south ? wp->w_height : 0);
int comp_col = (int)col - (east ? wp->w_width : 0);
+ comp_row += grid->comp_row;
+ comp_col += grid->comp_col;
comp_row = MAX(MIN(comp_row, Rows-wp->w_height_outer-1), 0);
comp_col = MAX(MIN(comp_col, Columns-wp->w_width_outer), 0);
wp->w_winrow = comp_row;