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

Make merged file hidden while changing layout #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

idbrii
Copy link

@idbrii idbrii commented Apr 16, 2020

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.

Fix samoshkin#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.
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.

Does not seem to work on MacOS
1 participant