Window navigation and netrw fixes #56
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes 3 issues that I stumbled upon as soon as I installed the plugin and started playing with it. Two of the issues were discovered because I am using non-default options in my vim configuration (
g:netrw_liststylesandsplitbelow). The other one should be visible for anyone using theNetrwplugin (even with the default configuration).I will be providing examples on how to reproduce these issues in a clean vim setup. For all setups we will use the same example directory structure, that I include in the attached file. The file should be extracted in the root directory of
vim-dirdiff.tree.zip
Structure after setup:
Suppress Netrw unlisted buffer deletion error
In the
diffwindow we can see something like the followingThen, we type,
j<CR>and we have selected thealphadirectory. Typing:ls!should output something similar to the followingWe can see the the
alphabuffer is "unlisted", meaning that abdeleteoperation will produce and error.After typing
j<CR>, to select thedelta.txtentry the following error should show in the statusline.Fix window navigation if 'splitbelow' is set
When opening with
splitbelowthe window structure should beTyping
hto togglehexmode will not work properly, because the thewincmdcommands inDirDiffHexModeexpect thediffwindow to be below the file windows.Fix Netrw window focus when g:netrw_liststyle = 3
The final bug is specific to the
Netrwconfiguration. Ifg:netrw_liststyle = 3(i.3. tree listing),Netrwwill create one additional buffer that is shared for all directory operations. This buffer has the nameNetrwTreeListing. If it is visible, instead of a buffer with the directory name, it means that we cannot focus on the correct window during diff entry selection changes. The original directory buffer is still there, but not displayed anymore.For all other values of the
g:netrw_liststyle, there is always one buffer created and its name is the same as the directory being displayed, so the bug is not showing up.Same as before the diff window contains
We type
j<CR>and thenAt this point the buffer with the directory name is visible and the current code would work. This is evident by calling
bufwinid.If we now focus on the
directorywindow, by typing<C-w>w, the situation changes.Netrwhas taken over and replaced the directory buffer in the visible window.If we now type
<C-w>wto get back to thediffwindow andj<CR>, the contents of the directory window won't change to those of thedelta.txtfile and this is because of the faulty focus logic in theDropfunction. There is no window visible named "alpha". The visible window isNetrwTreeListing.