mirror of
https://github.com/tpope/vim-fugitive.git
synced 2025-11-12 21:33:53 -05:00
Make status buffer diff retrieval asynchronous
Resolves: https://github.com/tpope/vim-fugitive/issues/1856
This commit is contained in:
@@ -2742,14 +2742,14 @@ function! fugitive#BufReadStatus() abort
|
||||
endfor
|
||||
endif
|
||||
|
||||
let diff = {'Staged': [], 'Unstaged': []}
|
||||
let diff = {'Staged': {'stdout': ['']}, 'Unstaged': {'stdout': ['']}}
|
||||
if len(staged)
|
||||
let diff['Staged'] =
|
||||
\ s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix', '--cached'])[0]
|
||||
\ fugitive#Execute(['diff', '--color=never', '--no-ext-diff', '--no-prefix', '--cached'], function('len'))
|
||||
endif
|
||||
if len(unstaged)
|
||||
let diff['Unstaged'] =
|
||||
\ s:LinesError(['diff', '--color=never', '--no-ext-diff', '--no-prefix'])[0]
|
||||
\ fugitive#Execute(['diff', '--color=never', '--no-ext-diff', '--no-prefix'], function('len'))
|
||||
endif
|
||||
let b:fugitive_diff = diff
|
||||
if v:cmdbang
|
||||
@@ -4671,7 +4671,7 @@ function! s:StageInline(mode, ...) abort
|
||||
let diff = []
|
||||
let index = 0
|
||||
let start = -1
|
||||
for line in b:fugitive_diff[info.section]
|
||||
for line in fugitive#Wait(b:fugitive_diff[info.section]).stdout
|
||||
if mode ==# 'await' && line[0] ==# '@'
|
||||
let mode = 'capture'
|
||||
endif
|
||||
@@ -4795,10 +4795,11 @@ function! s:StageApply(info, reverse, extra) abort
|
||||
endif
|
||||
let i = b:fugitive_expanded[info.section][info.filename][0]
|
||||
let head = []
|
||||
while get(b:fugitive_diff[info.section], i, '@') !~# '^@'
|
||||
let line = b:fugitive_diff[info.section][i]
|
||||
let diff_lines = fugitive#Wait(b:fugitive_diff[info.section]).stdout
|
||||
while get(diff_lines, i, '@') !~# '^@'
|
||||
let line = diff_lines[i]
|
||||
if line ==# '--- /dev/null'
|
||||
call add(head, '--- ' . get(b:fugitive_diff[info.section], i + 1, '')[4:-1])
|
||||
call add(head, '--- ' . get(diff_lines, i + 1, '')[4:-1])
|
||||
elseif line !~# '^new file '
|
||||
call add(head, line)
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user