Skip to content
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: Restore buffer local settings outside reviewer #446

Conversation

jakubbortlik
Copy link
Collaborator

@jakubbortlik jakubbortlik commented Dec 11, 2024

This PR fixes an issue originally reported in #347. After a closer inspection it is a gitlab.nvim bug, as currently we are removing keymaps and resetting 'modifiable' only for the currently active buffer, but not for other buffers previously shown by Diffview.

This PR fixes the issue by setting and deleting keymaps when entering any window that contains a Diffview buffer or when switching to a Diffview buffer without changing the window (i.e., cursor is already in the reviewer).

Edit: Apart from this fix, this PR also limits refreshing diagnostics to when the reviewer is entered, as opposed to the previous way when diagnostics were refreshed every time the reviewer buffer was changed. This speeds up the file switching significantly (although this is practically only noticeable when holding down <tab> to cycle between the diffs quickly which I don't think is something people do frequently 😄).

harrisoncramer and others added 30 commits September 16, 2024 16:34
Fixes scripts for running go tests and git tests
feat: Automatically open fold under cursor, redraw screen with cursor at center
* fix: use body with /mr/draft_notes/publish endpoint
* docs: notify about successfully building server
Fixed some bad warnings when the branch was out of date or ahead of the remote tracking branch. 

---------

Co-authored-by: Jakub F. Bortlík <[email protected]>
Fix: Show draft replies in the correct tree
fix: fixes wrong GET to gitlab when the URL includes namespacing. Fixes harrisoncramer#413.
@jakubbortlik
Copy link
Collaborator Author

jakubbortlik commented Dec 13, 2024

@briandipalma in August you reported the issue that I'm fixing in this PR, could you please try out this branch and let us know if it fixes the issue for you?

@briandipalma
Copy link
Contributor

I've just gone on holidays so I doubt I'll get the time to test this until after Christmas, I'll take a look in January.

@jakubbortlik jakubbortlik force-pushed the fix-buffer-local-settings-outside-reviewer branch from e5a5962 to 03bb696 Compare December 30, 2024 18:23
@harrisoncramer harrisoncramer force-pushed the develop branch 2 times, most recently from 3b57759 to 3b396a5 Compare January 18, 2025 16:23
@briandipalma
Copy link
Contributor

I've tried to recreate the issue but I'm failing so maybe it's gone, it was random so who knows. What I'll do is keep an eye out for the issue and if I see it I'll try this branch out. Sorry about taking so long.

Miscellaneous bug fixes and improvements.

docs: various improvements (harrisoncramer#445)
fix: don't jump to file from reviewer if it doesn't exist (harrisoncramer#452)
fix: force linewise motion in suggestion keybinding (harrisoncramer#454)
fix: prevent error after plenary job update (harrisoncramer#456)
fix: fix JSON on Windows (harrisoncramer#458)
fix: remove retry logic (harrisoncramer#449)
fix: check whether comment can be created (harrisoncramer#434)
@jakubbortlik
Copy link
Collaborator Author

I've tried to recreate the issue but I'm failing so maybe it's gone, it was random so who knows. What I'll do is keep an eye out for the issue and if I see it I'll try this branch out. Sorry about taking so long.

Hi Brian, thanks for having a look at this. Here's how you can reproduce the bug:

  1. Open a MR with multiple modified files
  2. In the Diffview File Panel press <tab> several times (or lua require("diffview.actions").select_next_entry())
  3. run :ls<cr>, you should see in the buffer list, that the previously visited buffers are nomodifiable
  4. In the File Panel or in one of the reviewer windows press gf which should open the file in another tab, where the current buffer is now modifiable and the commenting keymaps are removed (:map c should not show something like v c *@<Lua 1782: ~/projects/gitlab.nvim/lua/gitlab/reviewer/init.lua:384>\n Create comment for selected text.
  5. In the same tab (i.e., not the gitlab.nvim tab) open one of the other reviewed files (e.g., by running :bprev). This file will be nomodifiable and :map c will show that the commenting mappings are still there

In the jakubbortlik:fix-buffer-local-settings-outside-reviewer branch, this should be fixed, i.g., step 3 will still show that the buffer you've just cycled through with Diffview's <tab> keymap are still shown as nomodifiable, but when you do step 5, you'll see that upon visiting the buffer in another tab, the options and mappings are fixed.

@harrisoncramer harrisoncramer merged commit 79cf964 into harrisoncramer:develop Jan 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants