Skip to content

Commit c3d7f26

Browse files
fix: Allow reply on Gitlab buffer (#375)
Fixes issue where we were blocking reply creation due to a recent update This is a #PATCH release
1 parent dba1512 commit c3d7f26

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

cmd/app/server.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,14 @@ func CreateRouter(gitlabClient *Client, projectInfo *ProjectInfo, s *shutdownSer
233233
withMethodCheck(http.MethodPost),
234234
))
235235

236-
m.Handle("/ping", http.HandlerFunc(pingHandler))
236+
m.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
237+
w.WriteHeader(http.StatusOK)
238+
fmt.Fprintln(w, "pong")
239+
})
237240

238241
return LoggingServer{handler: m}
239242
}
240243

241-
/* Used to check whether the server has started yet */
242-
func pingHandler(w http.ResponseWriter, _ *http.Request) {
243-
w.WriteHeader(http.StatusOK)
244-
fmt.Fprintln(w, "pong")
245-
}
246-
247244
/* checkServer pings the server repeatedly for 1 full second after startup in order to notify the plugin that the server is ready */
248245
func checkServer(port int) error {
249246
for i := 0; i < 10; i++ {

lua/gitlab/actions/comment.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ end
156156
---@field ranged boolean
157157
---@field unlinked boolean
158158
---@field discussion_id string|nil
159+
---@field reply boolean|nil
159160

160161
---This function sets up the layout and popups needed to create a comment, note and
161162
---multi-line comment. It also sets up the basic keybindings for switching between
@@ -172,7 +173,7 @@ M.create_comment_layout = function(opts)
172173

173174
-- Check that Diffview is the current view
174175
local view = diffview_lib.get_current_view()
175-
if view == nil then
176+
if view == nil and not opts.reply then
176177
u.notify("Comments should be left in the reviewer pane", vim.log.levels.ERROR)
177178
return
178179
end
@@ -186,7 +187,7 @@ M.create_comment_layout = function(opts)
186187

187188
-- Check that we are hovering over the code
188189
local filetype = vim.bo[0].filetype
189-
if filetype == "DiffviewFiles" or filetype == "gitlab" then
190+
if not opts.reply and (filetype == "DiffviewFiles" or filetype == "gitlab") then
190191
u.notify(
191192
"Comments can only be left on the code. To leave unlinked comments, use gitlab.create_note() instead",
192193
vim.log.levels.ERROR

lua/gitlab/actions/discussions/init.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,16 @@ M.reply = function(tree)
244244
local discussion_id = tostring(discussion_node.id)
245245
local comment = require("gitlab.actions.comment")
246246
local unlinked = tree.bufnr == M.unlinked_bufnr
247-
local layout = comment.create_comment_layout({ ranged = false, discussion_id = discussion_id, unlinked = unlinked })
248-
layout:mount()
247+
local layout = comment.create_comment_layout({
248+
ranged = false,
249+
discussion_id = discussion_id,
250+
unlinked = unlinked,
251+
reply = true,
252+
})
253+
254+
if layout then
255+
layout:mount()
256+
end
249257
end
250258

251259
-- This function (settings.keymaps.discussion_tree.delete_comment) will trigger a popup prompting you to delete the current comment

0 commit comments

Comments
 (0)