aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/vim.c5
-rw-r--r--src/nvim/api/window.c31
2 files changed, 17 insertions, 19 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 7affb7c06c..f54ac5072c 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -1003,7 +1003,8 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
///
/// For a general overview of floats, see |api-floatwin|.
///
-/// Exactly one of `external` and `relative` must be specified.
+/// Exactly one of `external` and `relative` must be specified. The `width` and
+/// `height` of the new window must be specified.
///
/// With editor positioning row=0, col=0 refers to the top-left corner of the
/// screen-grid and row=Lines-1, Columns-1 refers to the bottom-right corner.
@@ -1035,7 +1036,7 @@ Buffer nvim_create_buf(Boolean listed, Boolean scratch, Error *err)
/// - "SW" south-west
/// - "SE" south-east
/// - `height`: window height (in character cells). Minimum of 1.
-/// - `width`: window width (in character cells). Minimum of 2.
+/// - `width`: window width (in character cells). Minimum of 1.
/// - `row`: row position. Screen cell height are used as unit. Can be
/// floating point.
/// - `col`: column position. Screen cell width is used as unit. Can be
diff --git a/src/nvim/api/window.c b/src/nvim/api/window.c
index 01cb9a6847..e1c50cb89d 100644
--- a/src/nvim/api/window.c
+++ b/src/nvim/api/window.c
@@ -466,8 +466,6 @@ void nvim_win_set_config(Window window, Dictionary config, Error *err)
if (!parse_float_config(config, &fconfig, !new_float, err)) {
return;
}
- fconfig.height = fconfig.height > 0 ? fconfig.height : win->w_height;
- fconfig.width = fconfig.width > 0 ? fconfig.width : win->w_width;
if (new_float) {
if (!win_new_float(win, fconfig, err)) {
return;
@@ -499,26 +497,25 @@ Dictionary nvim_win_get_config(Window window, Error *err)
return rv;
}
- PUT(rv, "width", INTEGER_OBJ(wp->w_float_config.width));
- PUT(rv, "height", INTEGER_OBJ(wp->w_float_config.height));
PUT(rv, "focusable", BOOLEAN_OBJ(wp->w_float_config.focusable));
PUT(rv, "external", BOOLEAN_OBJ(wp->w_float_config.external));
- PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
- float_anchor_str[wp->w_float_config.anchor])));
- if (wp->w_float_config.relative == kFloatRelativeWindow) {
- PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
- }
-
- if (wp->w_float_config.external) {
- return rv;
+ if (wp->w_floating) {
+ PUT(rv, "width", INTEGER_OBJ(wp->w_float_config.width));
+ PUT(rv, "height", INTEGER_OBJ(wp->w_float_config.height));
+ if (!wp->w_float_config.external) {
+ if (wp->w_float_config.relative == kFloatRelativeWindow) {
+ PUT(rv, "win", INTEGER_OBJ(wp->w_float_config.window));
+ }
+ PUT(rv, "anchor", STRING_OBJ(cstr_to_string(
+ float_anchor_str[wp->w_float_config.anchor])));
+ PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
+ PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
+ }
}
- PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
- PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
-
- const char *rel =
- wp->w_floating ? float_relative_str[wp->w_float_config.relative] : "";
+ const char *rel = (wp->w_floating && !wp->w_float_config.external
+ ? float_relative_str[wp->w_float_config.relative] : "");
PUT(rv, "relative", STRING_OBJ(cstr_to_string(rel)));
return rv;