Skip to content

Commit 6c5ff37

Browse files
committed
fix: honor is_draft from draft popup
1 parent 418640d commit 6c5ff37

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

lua/gitlab/actions/comment.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ local M = {
2222
}
2323

2424
---Decide if the comment is a draft based on the draft popup field.
25-
---@return boolean|nil is_draft True if the draft popup exists and the string it contains converts to `true`.
25+
---@return boolean|nil is_draft True if the draft popup exists and the string it contains converts to `true`. If the draft popup does not exist, return nil.
2626
local get_draft_value_from_popup = function()
2727
local buf_is_valid = M.draft_popup and M.draft_popup.bufnr and vim.api.nvim_buf_is_valid(M.draft_popup.bufnr)
28-
return buf_is_valid and u.string_to_bool(u.get_buffer_text(M.draft_popup.bufnr))
28+
if buf_is_valid then
29+
return u.string_to_bool(u.get_buffer_text(M.draft_popup.bufnr))
30+
else
31+
return nil
32+
end
2933
end
3034

3135
---Fires the API that sends the comment data to the Go server, called when you "confirm" creation
@@ -39,7 +43,10 @@ M.confirm_create_comment = function(text, unlinked, discussion_id)
3943
return
4044
end
4145

42-
local is_draft = get_draft_value_from_popup() or state.settings.discussion_tree.draft_mode
46+
local is_draft = get_draft_value_from_popup()
47+
if is_draft == nil then
48+
is_draft = state.settings.discussion_tree.draft_mode
49+
end
4350

4451
-- Creating a normal reply to a discussion
4552
if discussion_id ~= nil and not is_draft then

0 commit comments

Comments
 (0)