Skip to content

Draft: fix: improve discussions panel behaviour#552

Open
jakubbortlik wants to merge 21 commits intoharrisoncramer:developfrom
jakubbortlik:fix/open-discussions-immediately
Open

Draft: fix: improve discussions panel behaviour#552
jakubbortlik wants to merge 21 commits intoharrisoncramer:developfrom
jakubbortlik:fix/open-discussions-immediately

Conversation

@jakubbortlik
Copy link
Copy Markdown
Collaborator

This PR is based off my other PR #534, because it takes advantage of the async git system calls. That's why I'm putting it in Draft mode until #534 is merged.

This closes #510 and solves multiple other issues with the discussion panel:

  1. The discussion panel is now opened immediately after running :lua require("gitlab").review() or :lua require("gitlab").toggle_discussions() and the data is loaded after opening the split. This avoids the cursor focus being stolen with a delay or the discussions split being opened in an unexpected tab.
  2. The discussions panel can be configured so that the cursor is not placed in the split automatically after it opens.
  3. The cursor position is restored to the line and column anywhere in the discussion tree after rebuilding the tree and after toggling individual discussion nodes (before it was only restored after bulk toggle, always to the beginning of a line, and only if the cursor was already on a root node).
    • This required creating note body IDs as root node IDs + an index, rather than using random UUIDs. In my understanding, there was no real need for UUIDs for this and replacing with a simple root_node.id + line index has several benefits: Better cursor restoration, fewer lines of code.
  4. Autocommands are added that clean up the state when the discussion panel is closed so that toggling the discussions panel works correctly even after it was closed manually with something like :q.
  5. Discussion panel window options (nonumber, norelativenumber, breakindent, and showbreak) do not leak into the reviewer windows when toggling the discussions panel.
  6. The discussion split now has winfixbuf set so that no other buffer can be edited in the window (unless forced by the user).
  7. Buffer switching logic has been moved from the winbar module to the discussions module - this removes some of the spaghetti code that I introduced before.
  8. A deprecated function and some incorrect type annotations of optional parameters are fixed.

The `vim.api.nvim_get_current_tabpage()` function returns a tab ID, not
a tab number, as exemplified by the usage:
`vim.cmd.tabclose(vim.api.nvim_tabpage_get_number(M.tabid))`
Introducing more async git calls to prevent blocking UI (cursor and
winbar updates) when checking if the local branch is up-to-date with the
remote tracking branch. These checks can be async if we just want to
notify the user and the following actions are not blocked by the branch
being out-of-sync.
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.

Discussion window should be opened immediately

1 participant