api: refactor FloatRelative usage

This commit is contained in:
Marco Hinz
2019-03-16 15:34:16 +01:00
parent 86992a7bb1
commit 073ab7cda8
4 changed files with 16 additions and 22 deletions

View File

@@ -512,21 +512,9 @@ Dictionary nvim_win_get_config(Window window, Error *err)
PUT(rv, "row", FLOAT_OBJ(wp->w_float_config.row));
PUT(rv, "col", FLOAT_OBJ(wp->w_float_config.col));
if (wp->w_floating) {
switch (wp->w_float_config.relative) {
case kFloatRelativeEditor:
PUT(rv, "relative", STRING_OBJ(cstr_to_string("editor")));
break;
case kFloatRelativeWindow:
PUT(rv, "relative", STRING_OBJ(cstr_to_string("win")));
break;
case kFloatRelativeCursor:
PUT(rv, "relative", STRING_OBJ(cstr_to_string("cursor")));
break;
}
} else {
PUT(rv, "relative", STRING_OBJ(cstr_to_string("")));
}
const char *rel =
wp->w_floating ? float_relative_str[wp->w_float_config.relative] : "";
PUT(rv, "relative", STRING_OBJ(cstr_to_string(rel)));
return rv;
}