pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.24k stars 124 forks source link

Feature: LSP navigation updates diffs #538

Open delabere opened 2 months ago

delabere commented 2 months ago

Describe what this PR does / why we need it

When you navigate using LSP or a command like gf while reviewing a change using the use_local_fs option, you lose the diff, even if the file you navigated to was part of the change.

This change allows you to navigate around a PR's changed files using your LSP

https://github.com/pwntester/octo.nvim/assets/29151020/47f26fb0-3769-42c9-bfa0-4c76b756308f

Does this pull request fix one issue?

Fixes #535

Describe how you did it

Review layouts keep track of files, these are the files that you see populated in the files pane after opening a review. After entering a buffer, if the filepath is not octo://..., I assume that it is a local file and I check whether the file is part of the layout's file's. If it is then I update the review to that file using review.layout:set_file(file)

Describe how to verify it

You need to use use_local_fs and review a PR that has multiple files, where you can navigate between those files via LSP.

Special notes for reviews

There is some unintended behaviour with this change. When you navigate to the right buffer in the diff you see this message:

image

It doesn't happen if I comment out review.layout:set_file(file) in my change, so I assume that the side-effects of this are triggering more autocomands