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
This commit is contained in:
committed by
GitHub
parent
dba15127fe
commit
c3d7f26e3c
@@ -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++ {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user