Skip to content

Commit a5a7f37

Browse files
committed
refactor: deprecate create_multiline_comment
1 parent 86d238c commit a5a7f37

6 files changed

Lines changed: 29 additions & 46 deletions

File tree

cmd/app/comment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type DeleteCommentRequest struct {
4242
DiscussionId string `json:"discussion_id" validate:"required"`
4343
}
4444

45-
/* deleteComment deletes a note, multiline comment, or comment, which are all considered discussion notes. */
45+
/* deleteComment deletes a note or comment, which are all considered discussion notes. */
4646
func (a commentService) deleteComment(w http.ResponseWriter, r *http.Request) {
4747
payload := r.Context().Value(payload("payload")).(*DeleteCommentRequest)
4848

@@ -81,7 +81,7 @@ func (comment CommentWithPosition) GetPositionData() PositionData {
8181
return comment.PositionData
8282
}
8383

84-
/* postComment creates a note, multiline comment, or comment. */
84+
/* postComment creates a note or comment. */
8585
func (a commentService) postComment(w http.ResponseWriter, r *http.Request) {
8686
payload := r.Context().Value(payload("payload")).(*PostCommentRequest)
8787

doc/gitlab.nvim.txt

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -450,18 +450,15 @@ the configuration.
450450
REVIEWING AN MR *gitlab.nvim.reviewing-an-mr*
451451

452452
The `review` action will open a diff of the changes. You can leave comments
453-
using the `create_comment` action. In visual mode, add multiline comments with
454-
the `create_multiline_comment` command, and add suggested changes with the
453+
using the `create_comment` action, and add suggestions for changes with the
455454
`create_comment_suggestion` command:
456455
>lua
457456
require("gitlab").review()
458457
require("gitlab").create_comment()
459-
require("gitlab").create_multiline_comment()
460458
require("gitlab").create_comment_suggestion()
461459
<
462460
For suggesting changes you can use `create_comment_suggestion` in visual mode
463-
which works similar to `create_multiline_comment` but prefills the comment
464-
window with Gitlab’s suggest changes
461+
which prefills the comment window with Gitlab’s suggest changes
465462
<https://docs.gitlab.com/ee/user/project/merge_requests/reviews/suggestions.html>
466463
code block with prefilled code from the visual selection. Just like the
467464
summary, all the different kinds of comments are saved via the
@@ -883,33 +880,28 @@ have permission or has not previously approved the MR.
883880
*gitlab.nvim.create_comment*
884881
gitlab.create_comment() ~
885882

886-
Opens a popup to create a comment on the current line. Must be called when focused on the
887-
reviewer pane (see the gitlab.nvim.review command), otherwise it will error.
883+
Opens a popup to create a comment on the selected line(s) in the current
884+
buffer. Must be called when focused on the reviewer pane (see the
885+
|gitlab.nvim.review| command). In normal mode comments on the current line. In
886+
visual mode comments on the selected lines
888887
>lua
889888
require("gitlab").create_comment()
890-
891-
After the comment is typed, submit it to Gitlab via the
892-
`keymaps.popup.perform_action` keybinding, by default `ZZ`.
893-
894-
*gitlab.nvim.create_multiline_comment*
895-
gitlab.create_multiline_comment() ~
896-
897-
Opens a popup to create a multi-line comment. May only be called in visual
898-
mode, and will use the currently selected lines.
899-
>lua
900-
require("gitlab").create_multiline_comment()
901-
902-
After the comment is typed, submit it to Gitlab via the
903-
`keymaps.popup.perform_linewise_action` keybinding, by default `ZA`.
889+
<
890+
You can use the `keymaps.popup.perform_linewise_action` keybinding (by default
891+
`ZA`) to attach a file to the comment. After the comment is typed, submit it
892+
to Gitlab via the `keymaps.popup.perform_action` keybinding, by default `ZZ`.
893+
Discard the comment with `keymaps.popup.discard_changes` (`ZQ`), otherwise if
894+
you close the popup with something like `<c-w>q`, the comment contents are
895+
saved to the temporary register(s) (|gitlab.nvim.temp-registers|).
904896

905897
*gitlab.nvim.create_comment_suggestion*
906898
gitlab.create_comment_suggestion() ~
907899

908900
Opens a popup to create a comment suggestion (aka a comment that makes a committable
909901
change suggestion to the currently selected lines).
910902
>lua
911-
require("gitlab").create_multiline_comment()
912-
903+
require("gitlab").create_comment_suggestion()
904+
<
913905
After the comment is typed, submit it to Gitlab via the
914906
`keymaps.popup.perform_linewise_action` keybinding, by default `ZA`.
915907

lua/gitlab/actions/comment.lua

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,9 @@ M.create_comment_layout = function(opts)
220220
return layout
221221
end
222222

223-
--- This function will open a comment popup in order to create a comment on the changed/updated
224-
--- line in the current MR
223+
--- Creates a comment on the selected line(s) in the current buffer.
224+
--- In normal mode comments on the current line.
225+
--- In visual mode comments on the whole selection.
225226
M.create_comment = function()
226227
M.location = Location.new()
227228
if not M.can_create_comment(false) then
@@ -232,19 +233,6 @@ M.create_comment = function()
232233
layout:mount()
233234
end
234235

235-
--- This function will open a multi-line comment popup in order to create a multi-line comment
236-
--- on the changed/updated line in the current MR
237-
M.create_multiline_comment = function()
238-
M.location = Location.new()
239-
if not M.can_create_comment(true) then
240-
u.press_escape()
241-
return
242-
end
243-
244-
local layout = M.create_comment_layout({ unlinked = false })
245-
layout:mount()
246-
end
247-
248236
--- This function will open a a popup to create a "note" (e.g. unlinked comment)
249237
--- on the changed/updated line in the current MR
250238
M.create_note = function()
@@ -394,7 +382,7 @@ M.can_create_comment = function(must_be_visual)
394382
return false
395383
end
396384

397-
-- Check we're in visual mode for code suggestions and multiline comments
385+
-- Check we're in visual mode for code suggestions
398386
if must_be_visual and not u.check_visual_mode() then
399387
return false
400388
end

lua/gitlab/init.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ return {
7575
add_assignee = async.sequence({ info, project_members }, assignees_and_reviewers.add_assignee),
7676
delete_assignee = async.sequence({ info, project_members }, assignees_and_reviewers.delete_assignee),
7777
create_comment = async.sequence({ info, revisions }, comment.create_comment),
78-
create_multiline_comment = async.sequence({ info, revisions }, comment.create_multiline_comment),
78+
create_multiline_comment = async.sequence({ info, revisions }, function()
79+
u.notify("create_multiline_comment() is deprecated, use create_comment()", vim.log.levels.WARN)
80+
comment.create_comment()
81+
end),
7982
create_comment_suggestion = async.sequence({ info, revisions }, comment.create_comment_suggestion),
8083
create_comment_with_suggestion = async.sequence({ info, revisions }, comment.create_comment_with_suggestion),
8184
move_to_discussion_tree_from_diagnostic = async.sequence({}, discussions.move_to_discussion_tree),

lua/gitlab/reviewer/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ end
344344

345345
---Set the operatorfunc that will work on the lines defined by the motion that follows after the
346346
---operator mapping, and enter the operator-pending mode.
347-
---@param cb string Name of the gitlab.nvim API function to call, e.g., "create_multiline_comment".
347+
---@param cb string Name of the gitlab.nvim API function to call, e.g., "create_comment".
348348
local function execute_operatorfunc(cb)
349349
M.old_opfunc = vim.opt.operatorfunc
350350
M.old_winnr = vim.api.nvim_get_current_win()
@@ -385,12 +385,12 @@ M.set_keymaps = function(bufnr)
385385
keymaps.reviewer.create_comment,
386386
function()
387387
M.operator_count = vim.v.count
388-
execute_operatorfunc("create_multiline_comment")
388+
execute_operatorfunc("create_comment")
389389
end,
390390
{ buffer = bufnr, desc = "Create comment for range of motion", nowait = keymaps.reviewer.create_comment_nowait }
391391
)
392392
vim.keymap.set("v", keymaps.reviewer.create_comment, function()
393-
require("gitlab").create_multiline_comment()
393+
require("gitlab").create_comment()
394394
end, {
395395
buffer = bufnr,
396396
desc = "Create comment for selected text",

lua/gitlab/utils/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ end
588588
M.check_visual_mode = function()
589589
local mode = vim.api.nvim_get_mode().mode
590590
if mode ~= "v" and mode ~= "V" then
591-
M.notify("Code suggestions and multiline comments are only available in visual mode", vim.log.levels.ERROR)
591+
M.notify("Code suggestions are only available in visual mode", vim.log.levels.ERROR)
592592
return false
593593
end
594594
return true

0 commit comments

Comments
 (0)