{"action":"created","issue":{"url":"https://api.github.com/repos/tpope/vim-fugitive/issues/1019","repository_url":"https://api.github.com/repos/tpope/vim-fugitive","labels_url":"https://api.github.com/repos/tpope/vim-fugitive/issues/1019/labels{/name}","comments_url":"https://api.github.com/repos/tpope/vim-fugitive/issues/1019/comments","events_url":"https://api.github.com/repos/tpope/vim-fugitive/issues/1019/events","html_url":"https://github.com/tpope/vim-fugitive/issues/1019","id":315285870,"number":1019,"title":"Gdiff: any BufWritePost autocommand disables diff mode when writing index buffer","user":{"login":"smancill","id":238528,"avatar_url":"https://avatars3.githubusercontent.com/u/238528?v=4","gravatar_id":"","url":"https://api.github.com/users/smancill","html_url":"https://github.com/smancill","followers_url":"https://api.github.com/users/smancill/followers","following_url":"https://api.github.com/users/smancill/following{/other_user}","gists_url":"https://api.github.com/users/smancill/gists{/gist_id}","starred_url":"https://api.github.com/users/smancill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smancill/subscriptions","organizations_url":"https://api.github.com/users/smancill/orgs","repos_url":"https://api.github.com/users/smancill/repos","events_url":"https://api.github.com/users/smancill/events{/privacy}","received_events_url":"https://api.github.com/users/smancill/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-18T00:20:32Z","updated_at":"2018-04-25T17:03:28Z","closed_at":"2018-04-25T17:03:28Z","author_association":"NONE","body":"How to reproduce:\r\n\r\n1. Open a modified file and run `Gdiff` (see below for contents of `minimal.vim`):\r\n\r\n        vim -u minimal.vim -U none -i none +Gdiff vimrc\r\n\r\n2. The diff looks fine:\r\n\r\n    <img width=\"888\" alt=\"captura de pantalla 2018-04-17 a la s 20 54 52\" src=\"https://user-images.githubusercontent.com/238528/38904709-71102302-4282-11e8-8aaf-3326b5304fb5.png\">\r\n\r\n3. But now write the *index* buffer (`:w`), the diff mode is gone:\r\n\r\n    <img width=\"891\" alt=\"captura de pantalla 2018-04-17 a la s 20 55 05\" src=\"https://user-images.githubusercontent.com/238528/38904782-c96c627c-4282-11e8-8ff6-68a07566638f.png\">\r\n\r\n    Both buffers now get out of sync when scrolling, the diff syntax acts all weird, etc.\r\n    \r\n4. The diff mode can be restored by running `:diffthis` in the *index* buffer after the `:w`.\r\n\r\nI have tracked the problem to any user defined `BufWritePost` autocommand running when the fugitive buffer is saved.\r\n\r\n`minimal.vim` (using [vim-plug](https://github.com/junegunn/vim-plug)):\r\n```vim\r\nset nocompatible\r\n\r\ncall plug#begin('~/.vim/bundle')\r\n\r\nPlug 'tpope/vim-sensible'\r\nPlug 'tpope/vim-fugitive'\r\n\r\naugroup minimal\r\nautocmd!\r\nautocmd BufWritePost * echomsg \"New BufWritePost autocmd\"\r\naugroup end\r\n\r\ncall plug#end()\r\n```\r\n\r\nIf the autocommand is removed, then everything works fine.\r\n\r\nVim version:\r\n```\r\nVIM - Vi IMproved 8.0 (2016 Sep 12, compiled Apr 13 2018 06:21:17)\r\nmacOS version\r\nIncluded patches: 1-1700\r\nCompiled by Homebrew\r\nHuge version without GUI.  Features included (+) or not (-):\r\n+acl               +farsi             +mouse_sgr         -tag_any_white\r\n+arabic            +file_in_path      -mouse_sysmouse    -tcl\r\n+autocmd           +find_in_path      +mouse_urxvt       +termguicolors\r\n-autoservername    +float             +mouse_xterm       +terminal\r\n-balloon_eval      +folding           +multi_byte        +terminfo\r\n+balloon_eval_term -footer            +multi_lang        +termresponse\r\n-browse            +fork()            -mzscheme          +textobjects\r\n++builtin_terms    -gettext           +netbeans_intg     +timers\r\n+byte_offset       -hangul_input      +num64             +title\r\n+channel           +iconv             +packages          -toolbar\r\n+cindent           +insert_expand     +path_extra        +user_commands\r\n-clientserver      +job               +perl              +vertsplit\r\n+clipboard         +jumplist          +persistent_undo   +virtualedit\r\n+cmdline_compl     +keymap            +postscript        +visual\r\n+cmdline_hist      +lambda            +printer           +visualextra\r\n+cmdline_info      +langmap           +profile           +viminfo\r\n+comments          +libcall           -python            +vreplace\r\n+conceal           +linebreak         +python3           +wildignore\r\n+cryptv            +lispindent        +quickfix          +wildmenu\r\n+cscope            +listcmds          +reltime           +windows\r\n+cursorbind        +localmap          +rightleft         +writebackup\r\n+cursorshape       -lua               +ruby              -X11\r\n+dialog_con        +menu              +scrollbind        -xfontset\r\n+diff              +mksession         +signs             -xim\r\n+digraphs          +modify_fname      +smartindent       -xpm\r\n-dnd               +mouse             +startuptime       -xsmp\r\n-ebcdic            -mouseshape        +statusline        -xterm_clipboard\r\n+emacs_tags        +mouse_dec         -sun_workshop      -xterm_save\r\n+eval              -mouse_gpm         +syntax            \r\n+ex_extra          -mouse_jsbterm     +tag_binary        \r\n+extra_search      +mouse_netterm     +tag_old_static    \r\n   system vimrc file: \"$VIM/vimrc\"\r\n     user vimrc file: \"$HOME/.vimrc\"\r\n 2nd user vimrc file: \"~/.vim/vimrc\"\r\n      user exrc file: \"$HOME/.exrc\"\r\n       defaults file: \"$VIMRUNTIME/defaults.vim\"\r\n  fall-back for $VIM: \"/usr/local/share/vim\"\r\nCompilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       \r\nLinking: clang   -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -framework AppKit   -mmacosx-version-min=10.12 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.26.1/lib/perl5/5.26.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framework CoreFoundation  -lruby.2.5.1 -lobjc    \r\n```\r\n\r\n\r\nFugitive version:\r\n```\r\nv2.2-129-g40d78f07dee2\r\n```\r\n\r\nGit version:\r\n```\r\ngit version 2.17.0\r\n```\r\n\r\nSystem version:\r\n```\r\nProductName:\tMac OS X\r\nProductVersion:\t10.12.4\r\nBuildVersion:\t16E195\r\n```\r\n\r\nI am not sure if the problem is with Fugitive or introduced by a Vim update. Vim 7.4 (the system version distributed with macOS) works fine. "},"comment":{"url":"https://api.github.com/repos/tpope/vim-fugitive/issues/comments/384360845","html_url":"https://github.com/tpope/vim-fugitive/issues/1019#issuecomment-384360845","issue_url":"https://api.github.com/repos/tpope/vim-fugitive/issues/1019","id":384360845,"user":{"login":"smancill","id":238528,"avatar_url":"https://avatars3.githubusercontent.com/u/238528?v=4","gravatar_id":"","url":"https://api.github.com/users/smancill","html_url":"https://github.com/smancill","followers_url":"https://api.github.com/users/smancill/followers","following_url":"https://api.github.com/users/smancill/following{/other_user}","gists_url":"https://api.github.com/users/smancill/gists{/gist_id}","starred_url":"https://api.github.com/users/smancill/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smancill/subscriptions","organizations_url":"https://api.github.com/users/smancill/orgs","repos_url":"https://api.github.com/users/smancill/repos","events_url":"https://api.github.com/users/smancill/events{/privacy}","received_events_url":"https://api.github.com/users/smancill/received_events","type":"User","site_admin":false},"created_at":"2018-04-25T17:03:28Z","updated_at":"2018-04-25T17:03:28Z","author_association":"NONE","body":"Fixed by one of the patches between Vim 8.0.1700 and 8.0.1750 (after updating the Homebrew version)."}}
{"actor":{"display_login":"smancill"}}