diff options
| author | Peter Cardenas <16930781+PeterCardenas@users.noreply.github.com> | 2026-04-24 08:57:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-24 11:57:35 -0400 |
| commit | 27191e0f4f4f9086180a8fbe3e52c1c280a70b09 (patch) | |
| tree | 7db425cbd45fbc5a32ed2a937691bdd7019d6cbc /src/nvim/api/vim.c | |
| parent | a57fab2f2d852ec33bdbcb7fc8b90d611e6a653b (diff) | |
feat(api): nvim_echo(percent=nil) means "unknown" progress #39029
Problem:
No way to signal "unknown" or "indeterminate" progress percentage.
Solution:
Treat percent=nil as "indeterminate" percent.
Diffstat (limited to 'src/nvim/api/vim.c')
| -rw-r--r-- | src/nvim/api/vim.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9adc4914a8..ce9018a218 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -824,7 +824,7 @@ void nvim_set_vvar(String name, Object value, Error *err) /// instead of creating a new message. /// - kind (`string?`) Decides the |ui-messages| kind in the emitted message. Set "progress" /// to emit a |progress-message|. -/// - percent (`integer?`) |progress-message| percentage. +/// - percent (`integer?`) |progress-message| percentage, or nil to signal "unknown progress". /// - source (`string?`) |progress-message| source. /// - status (`string?`) |progress-message| status: /// - "success": Process completed successfully. @@ -857,7 +857,7 @@ Union(Integer, String) nvim_echo(ArrayOf(Tuple(String, *HLGroupID)) chunks, Bool bool needs_clear = !history; VALIDATE(is_progress - || (opts->status.size == 0 && opts->title.size == 0 && opts->percent == 0 + || (opts->status.size == 0 && opts->title.size == 0 && !HAS_KEY(opts, echo_opts, percent) && opts->data.size == 0 && opts->source.size == 0), "Conflict: title/source/status/percent/data not allowed with kind='%s'", kind, { @@ -872,7 +872,8 @@ Union(Integer, String) nvim_echo(ArrayOf(Tuple(String, *HLGroupID)) chunks, Bool goto error; }); - VALIDATE_RANGE(!is_progress || (opts->percent >= 0 && opts->percent <= 100), + VALIDATE_RANGE(!is_progress || !HAS_KEY(opts, echo_opts, percent) + || (opts->percent >= 0 && opts->percent <= 100), "percent", { goto error; }); @@ -888,8 +889,8 @@ Union(Integer, String) nvim_echo(ArrayOf(Tuple(String, *HLGroupID)) chunks, Bool }); MessageData msg_data = { .title = opts->title, .status = opts->status, - .percent = opts->percent, .data = opts->data, - .source = opts->source }; + .percent = HAS_KEY(opts, echo_opts, percent) ? opts->percent : -1, + .data = opts->data, .source = opts->source }; const bool save_nwr = need_wait_return; const int save_lines_left = lines_left; |
