diff options
author | andrew-pa <andrew.pa@outlook.com> | 2021-06-10 20:07:52 -0700 |
---|---|---|
committer | andrew-pa <andrew.pa@outlook.com> | 2021-09-08 10:31:47 -0600 |
commit | 9065730680d1a52f7487ff555bdb1f5b11904c88 (patch) | |
tree | a95c9d86f9e0523e72ac0c2089d686ddcdb0d655 /src | |
parent | 1df8a34a7b91028413d6ac751b9dbf9fdcd6cda2 (diff) | |
download | rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.tar.gz rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.tar.bz2 rneovim-9065730680d1a52f7487ff555bdb1f5b11904c88.zip |
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.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index aea60fe24c..acdc40dc74 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; |