diff --git a/cmd/app/server.go b/cmd/app/server.go index 9774011e..342eb947 100644 --- a/cmd/app/server.go +++ b/cmd/app/server.go @@ -233,17 +233,14 @@ func CreateRouter(gitlabClient *Client, projectInfo *ProjectInfo, s *shutdownSer withMethodCheck(http.MethodPost), )) - m.Handle("/ping", http.HandlerFunc(pingHandler)) + m.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + fmt.Fprintln(w, "pong") + }) return LoggingServer{handler: m} } -/* Used to check whether the server has started yet */ -func pingHandler(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(http.StatusOK) - fmt.Fprintln(w, "pong") -} - /* checkServer pings the server repeatedly for 1 full second after startup in order to notify the plugin that the server is ready */ func checkServer(port int) error { for i := 0; i < 10; i++ { diff --git a/lua/gitlab/actions/comment.lua b/lua/gitlab/actions/comment.lua index daadd3be..95abe305 100644 --- a/lua/gitlab/actions/comment.lua +++ b/lua/gitlab/actions/comment.lua @@ -156,6 +156,7 @@ end ---@field ranged boolean ---@field unlinked boolean ---@field discussion_id string|nil +---@field reply boolean|nil ---This function sets up the layout and popups needed to create a comment, note and ---multi-line comment. It also sets up the basic keybindings for switching between @@ -172,7 +173,7 @@ M.create_comment_layout = function(opts) -- Check that Diffview is the current view local view = diffview_lib.get_current_view() - if view == nil then + if view == nil and not opts.reply then u.notify("Comments should be left in the reviewer pane", vim.log.levels.ERROR) return end @@ -186,7 +187,7 @@ M.create_comment_layout = function(opts) -- Check that we are hovering over the code local filetype = vim.bo[0].filetype - if filetype == "DiffviewFiles" or filetype == "gitlab" then + if not opts.reply and (filetype == "DiffviewFiles" or filetype == "gitlab") then u.notify( "Comments can only be left on the code. To leave unlinked comments, use gitlab.create_note() instead", vim.log.levels.ERROR diff --git a/lua/gitlab/actions/discussions/init.lua b/lua/gitlab/actions/discussions/init.lua index 5e7cfdda..571fe47f 100644 --- a/lua/gitlab/actions/discussions/init.lua +++ b/lua/gitlab/actions/discussions/init.lua @@ -244,8 +244,16 @@ M.reply = function(tree) local discussion_id = tostring(discussion_node.id) local comment = require("gitlab.actions.comment") local unlinked = tree.bufnr == M.unlinked_bufnr - local layout = comment.create_comment_layout({ ranged = false, discussion_id = discussion_id, unlinked = unlinked }) - layout:mount() + local layout = comment.create_comment_layout({ + ranged = false, + discussion_id = discussion_id, + unlinked = unlinked, + reply = true, + }) + + if layout then + layout:mount() + end end -- This function (settings.keymaps.discussion_tree.delete_comment) will trigger a popup prompting you to delete the current comment