aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-09-19 11:49:59 +0200
committerGitHub <noreply@github.com>2023-09-19 11:49:59 +0200
commit2de5cddeb197502c8b3ecf5e7eb1ac929cc2307f (patch)
tree7b7baf5a45d1c3b44399125005e535412956b211 /src
parent6405fa4b117263b92f87b17150abd2d1c6ab5881 (diff)
parentfd08fd3de3020647c8ae73f1c7d2cf9a4926c828 (diff)
downloadrneovim-2de5cddeb197502c8b3ecf5e7eb1ac929cc2307f.tar.gz
rneovim-2de5cddeb197502c8b3ecf5e7eb1ac929cc2307f.tar.bz2
rneovim-2de5cddeb197502c8b3ecf5e7eb1ac929cc2307f.zip
Merge pull request #25148 from glepnir/fixed_opt
fix(float): add fixed option
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/keysets.h1
-rw-r--r--src/nvim/api/win_config.c6
-rw-r--r--src/nvim/buffer_defs.h4
-rw-r--r--src/nvim/window.c4
4 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/api/keysets.h b/src/nvim/api/keysets.h
index 4e5e7af619..736ca9ce07 100644
--- a/src/nvim/api/keysets.h
+++ b/src/nvim/api/keysets.h
@@ -112,6 +112,7 @@ typedef struct {
String footer_pos;
String style;
Boolean noautocmd;
+ Boolean fixed;
} Dict(float_config);
typedef struct {
diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c
index 63cf3bb701..9bb7f14a72 100644
--- a/src/nvim/api/win_config.c
+++ b/src/nvim/api/win_config.c
@@ -163,6 +163,8 @@
/// - noautocmd: If true then no buffer-related autocommand events such as
/// |BufEnter|, |BufLeave| or |BufWinEnter| may fire from
/// calling this function.
+/// - fixed: If true when anchor is NW or SW, the float window
+/// would be kept fixed even if the window would be truncated.
///
/// @param[out] err Error details, if any
///
@@ -845,6 +847,10 @@ static bool parse_float_config(Dict(float_config) *config, FloatConfig *fconfig,
fconfig->noautocmd = config->noautocmd;
}
+ if (HAS_KEY_X(config, fixed)) {
+ fconfig->fixed = config->fixed;
+ }
+
return true;
#undef HAS_KEY_X
}
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 3229cb2fe7..c09de30bc1 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -966,6 +966,7 @@ typedef struct {
VirtText footer_chunks;
int footer_width;
bool noautocmd;
+ bool fixed;
} FloatConfig;
#define FLOAT_CONFIG_INIT ((FloatConfig){ .height = 0, .width = 0, \
@@ -975,7 +976,8 @@ typedef struct {
.focusable = true, \
.zindex = kZIndexFloatDefault, \
.style = kWinStyleUnused, \
- .noautocmd = false })
+ .noautocmd = false, \
+ .fixed = false })
// Structure to store last cursor position and topline. Used by check_lnums()
// and reset_lnums().
diff --git a/src/nvim/window.c b/src/nvim/window.c
index c0d399c4c4..10334083ce 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -1010,6 +1010,10 @@ void ui_ext_win_position(win_T *wp, bool validate)
comp_col += grid->comp_col;
comp_row = MAX(MIN(comp_row, Rows - wp->w_height_outer - (p_ch > 0 ? 1 : 0)), 0);
comp_col = MAX(MIN(comp_col, Columns - wp->w_width_outer), 0);
+ int right_extra = Columns - (int)c.col - wp->w_width - (c.border_chars[2][0] != 0);
+ if (!(c.anchor & kFloatAnchorEast) && c.fixed && right_extra < 0) {
+ comp_col = (int)c.col;
+ }
wp->w_winrow = comp_row;
wp->w_wincol = comp_col;
ui_comp_put_grid(&wp->w_grid_alloc, comp_row, comp_col,