Make merged file hidden while changing layout #15
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.
Fix #12: We were assuming users had 'hidden' set.
mergetool#start ends with two steps: prefer_revision and set_layout.
prefer_revision modifies the current buffer to remove conflict markers.
set_layout closes all but the first window in g:mergetool_layout and
then shows the other windows in order.
If a user has these combination of settings, closing the merge buffer's
window will trigger an error:
set nohidden
let g:mergetool_layout = 'rm'
We modify the merge buffer (without saving it -- so the user knows we
made changes) and then we try to close it (because 'm' is not the first
item in mergetool_layout), which triggers an "unsaved changes" error.
Prevent the error by temporarily marking the merge buffer to hide while
we're modifying the layout.
Uses setbufvar (introduced to vim in 7.0) to clean up so if the user
doesn't include 'm' in the layout, we don't fail to clean up. And in
that case, the merge buffer is already hidden, so it doesn't cause
unsaved errors until it's shown again.