aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/vim.c
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@protonmail.com>2021-10-19 20:35:44 +0600
committerGitHub <noreply@github.com>2021-10-19 07:35:44 -0700
commitda7a4684df326892718aff9056767d4620b567c3 (patch)
tree971c57c9bd4af456e54f2405e4bb9e4a709b5889 /src/nvim/api/vim.c
parent9fb0f12357b663fd8571010b2b8659a063af253e (diff)
downloadrneovim-da7a4684df326892718aff9056767d4620b567c3.tar.gz
rneovim-da7a4684df326892718aff9056767d4620b567c3.tar.bz2
rneovim-da7a4684df326892718aff9056767d4620b567c3.zip
fix(api/nvim_eval_statusline): allow maxwidth=0 #16080
Allows disabling statusline truncation by allowing maxwidth to be set to 0 in `nvim_eval_statusline`.
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r--src/nvim/api/vim.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index a3143efe0c..233fd82d3c 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -2933,9 +2933,9 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
{
Dictionary result = ARRAY_DICT_INIT;
- Window window = 0;
- int maxwidth = 0;
+ int maxwidth;
char fillchar = 0;
+ Window window = 0;
bool use_tabline = false;
bool highlights = false;
@@ -2948,15 +2948,6 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
window = (Window)opts->winid.data.integer;
}
- if (HAS_KEY(opts->maxwidth)) {
- if (opts->maxwidth.type != kObjectTypeInteger) {
- api_set_error(err, kErrorTypeValidation, "maxwidth must be an integer");
- return result;
- }
-
- maxwidth = (int)opts->maxwidth.data.integer;
- }
-
if (HAS_KEY(opts->fillchar)) {
if (opts->fillchar.type != kObjectTypeString || opts->fillchar.data.string.size > 1) {
api_set_error(err, kErrorTypeValidation, "fillchar must be an ASCII character");
@@ -2998,7 +2989,14 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
}
}
- if (maxwidth == 0) {
+ if (HAS_KEY(opts->maxwidth)) {
+ if (opts->maxwidth.type != kObjectTypeInteger) {
+ api_set_error(err, kErrorTypeValidation, "maxwidth must be an integer");
+ return result;
+ }
+
+ maxwidth = (int)opts->maxwidth.data.integer;
+ } else {
maxwidth = use_tabline ? Columns : wp->w_width;
}