Skip to content

Commit

Permalink
fix!: Data-cell automatically turn on fail_if_empty if default is…
Browse files Browse the repository at this point in the history
… not set
  • Loading branch information
idanarye committed Jan 2, 2025
1 parent 3c899db commit 468c9ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/moonicipal.txt
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ MoonicipalCachedDataCellOptions *MoonicipalCachedDataCellOptions*
If set to a string, use that string as the error message instead of the
default generated template.

Note that this is automatically turned on if `default` is not set. If this
behavior is not desired, it can manually be set to `false`.


MoonicipalTask:cached_data_cell({opts}) *MoonicipalTask:cached_data_cell*
Create a data cell - a buffer where the user can put data for other tasks to
Expand Down
5 changes: 4 additions & 1 deletion lua/moonicipal/Task.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ end
---
---If set to a string, use that string as the error message instead of the
---default generated template.
---
---Note that this is automatically turned on if `default` is not set. If this
---behavior is not desired, it can manually be set to `false`.
---@field fail_if_empty? boolean | string

---Create a data cell - a buffer where the user can put data for other tasks to
Expand Down Expand Up @@ -181,7 +184,7 @@ function MoonicipalTask:cached_data_cell(opts)
if existing_buf_nr then
local lines = vim.api.nvim_buf_get_lines(existing_buf_nr, 0, -1, true)
return table.concat(lines, '\n')
elseif opts.fail_if_empty then
elseif opts.fail_if_empty or (opts.fail_if_empty == nil and not opts.default) then
if type(opts.fail_if_empty) == 'string' then
util.abort(opts.fail_if_empty)
else
Expand Down

0 comments on commit 468c9ee

Please sign in to comment.