Closed nkakouros closed 5 years ago
Changing
autocmd BufWritePre *.sh Shfmt
autocmd FileType sh autocmd BufWritePre <buffer> Shfmt
to
autocmd BufWritePost *.sh Shfmt
autocmd FileType sh autocmd BufWritePost <buffer> Shfmt
seems to solve the issue of losing the changes. But the undo history issue remains. The problem is not that the history gets emptied as I mentioned, but that it fills with a lot of 'no-op' records.
This might be relevant to the undo history issue https://stackoverflow.com/questions/24690441/call-a-function-without-adding-to-undo-list
I am at my limits of vimscript here to move further.
@tterranigma Thanks for the report, and sorry about the delay in getting to this. I have just updated master (#3) with your change, and it is still working for me. I don't really know how to handle the undo history problem right now, but I have been looking at other similar plugins which also don't handle this well, so not sure how best to solve that one.
CC: @sublimino @radioinmyhead
I think the logic of the plugin it to before saving to format the file. But the file that is being formatted is the one without the changes and this is what is being saved.
Probably related to the above is the fact that the undo history gets deleted for the file in question after saving, even if
set hidden
is present.