Tighten up autowrite handling

This commit is contained in:
Tim Pope 2019-07-12 14:38:28 -04:00
parent d0049b4417
commit 0c259e3016

View File

@ -2030,10 +2030,10 @@ function! s:GitExec(line1, line2, range, count, bang, mods, reg, args, dir) abor
\ s:HasOpt(a:args, ['add', 'clean', 'stage'], '-i', '--interactive') \ s:HasOpt(a:args, ['add', 'clean', 'stage'], '-i', '--interactive')
let mods = substitute(s:Mods(a:mods), '\<tab\>', '-tab', 'g') let mods = substitute(s:Mods(a:mods), '\<tab\>', '-tab', 'g')
if has('nvim') if has('nvim')
if &autowrite | wall | endif if &autowrite || &autowriteall | silent! wall | endif
return mods . (a:count ? 'split' : 'edit') . ' term://' . s:fnameescape(s:shellesc(git + a:args)) . '|startinsert' return mods . (a:count ? 'split' : 'edit') . ' term://' . s:fnameescape(s:shellesc(git + a:args)) . '|startinsert'
elseif has('terminal') elseif has('terminal')
if &autowrite | wall | endif if &autowrite || &autowriteall | silent! wall | endif
return 'exe ' . string(mods . 'terminal ' . (a:count ? '' : '++curwin ') . join(map(git + a:args, 's:fnameescape(v:val)'))) return 'exe ' . string(mods . 'terminal ' . (a:count ? '' : '++curwin ') . join(map(git + a:args, 's:fnameescape(v:val)')))
endif endif
endif endif
@ -2983,8 +2983,8 @@ function! s:CommitCommand(line1, line2, range, count, bang, mods, reg, arg, args
let exec_error = v:shell_error let exec_error = v:shell_error
call delete(errorfile) call delete(errorfile)
else else
if &autowrite && !a:0 if (&autowrite || &autowriteall) && !a:0
wall silent! wall
endif endif
let [error_string, exec_error] = s:TempCmd(outfile, command) let [error_string, exec_error] = s:TempCmd(outfile, command)
let errors = split(error_string, "\n") let errors = split(error_string, "\n")
@ -3247,21 +3247,17 @@ function! s:MergeRebase(cmd, bang, mods, args, ...) abort
else else
let &l:makeprg = 'env GIT_EDITOR=false ' . substitute(&l:makeprg, '^env ', '', '') let &l:makeprg = 'env GIT_EDITOR=false ' . substitute(&l:makeprg, '^env ', '', '')
endif endif
try if !has('patch-8.1.0334') && has('terminal') && &autowrite
if !has('patch-8.1.0334') && &autowrite
let autowrite_was_set = 1 let autowrite_was_set = 1
set noautowrite set noautowrite
wall silent! wall
endif endif
silent noautocmd make! silent noautocmd make!
let err = v:exception
finally finally
if exists('autowrite_was_set') if exists('autowrite_was_set')
set autowrite set autowrite
endif endif
endtry
catch /^Vim\%((\a\+)\)\=:E211/
let err = v:exception
finally
redraw! redraw!
let [&l:mp, &l:efm] = [mp, efm] let [&l:mp, &l:efm] = [mp, efm]
if exists('old_editor') if exists('old_editor')
@ -3851,10 +3847,10 @@ function! s:Dispatch(bang, cmd, arg) abort
Make Make
return after[1:-1] return after[1:-1]
else else
if !has('patch-8.1.0334') && &autowrite if !has('patch-8.1.0334') && has('terminal') && &autowrite
let autowrite_was_set = 1 let autowrite_was_set = 1
set noautowrite set noautowrite
wall silent! wall
endif endif
silent noautocmd make! silent noautocmd make!
redraw! redraw!