-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: comment creation should not be possible for renamed and moved files #416
fix: comment creation should not be possible for renamed and moved files #416
Conversation
@jakubbortlik I believe this resolves your issues with renamed files. You are able to leave comments on renamed files with these changes, so long as they have modifications. Normal, unmodified but renamed files will throw an error as those are not supported. Please let me know if this resolves your issues. |
"--no-color", | ||
base_sha, | ||
"--", | ||
reviewer.get_current_file_oldpath(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Include the old path when calculating the diff, since the new file may have a different path
Hi Harrison, thanks for doing this! It works in that commenting on renamed files is disabled, but for some default commenting keybindings, more errors are shown than intended: The normal mode keybinding
This can be fixed by returning early from M lua/gitlab/actions/comment.lua
@@ -359,6 +359,8 @@ M.create_comment_suggestion = function()
local layout = M.create_comment_layout({ ranged = range_length > 0, unlinked = false })
if layout ~= nil then
layout:mount()
+ else
+ return
end
vim.schedule(function()
if suggestion_lines then The keybindings
This will possibly require some fixes of how the callback is executed for the operator mappings. I haven't found a trivial fix when briefly investigating this. Also, interestingly when the |
A possible solution for the error |
I've fixed the first issue you pointed out, using your provided solution. I'm not seeing the second issue at all, ranged comments or suggestions are just giving me the single error message. |
Interesting. I'll find out what the problem is and let you know. |
Hi @harrisoncramer, you should be able to reproduce the issue with this config: -- This is a minimal init.lua that is used for debugging
local root = vim.fn.stdpath("run") .. "/nvim/mininit"
vim.fn.mkdir(root, "p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"harrisoncramer/gitlab.nvim",
dir = "~/projects/gitlab.nvim/",
dependencies = {
"MunifTanjim/nui.nvim",
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim",
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
"nvim-tree/nvim-web-devicons" -- Recommended but not required. Icons in discussion tree.
},
enabled = true,
build = function() require("gitlab.server").build(true) end, -- Builds the Go binary
config = function()
require("gitlab").setup({
colors = {
discussion_tree = {
mention = "Keyword", -- Overrides to get rid of errors due to missing colors...
directory = "Keyword",
resolved = "Keyword",
unresolved = "Keyword",
draft = "Keyword"
},
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
}) The way I understand this is that the problem is in lines 292-295 in vim.api.nvim_cmd(
{ cmd = "lua", args = { ("require'gitlab'.%s()"):format(callback) }, mods = { lockmarks = true } },
{}
) The docs on I've looked at your nvim config and you seem to be using |
This is because
|
Maybe the cursor-restoration logic could be moved from operatorfunc callback ( |
Feel free to change the cursor restoration logic in a separate MR if you'd like, it's not really a top priority for me and you seem to understand the issue quite well. I'm just going to merge this MR as-is, since it resolves the original issue here. Thanks for digging into this so deeply and helping me resolve those edge cases. |
fix: Show non-resolvable notes in winbar (#417) fix: add more emojis and make emoji picker configurable (#414) fix: comment creation should not be possible for renamed and moved files (#416) fix: color highlight groups are invalid (#421) fix: plugin failing to build on Windows (#419) --------- Co-authored-by: Jakub F. Bortlík <[email protected]>
Makes it not possible to leave comments on renamed files