From 7493b78e6b5fc018c17bb020e20b436a838528a1 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sun, 19 May 2024 10:51:19 -0400 Subject: [PATCH] Fix :Git difftool without -y Resolves: https://github.com/tpope/vim-fugitive/issues/2307 --- autoload/fugitive.vim | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 9eb928c..7602266 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -5481,10 +5481,8 @@ function! s:ToolItems(state, from, to, offsets, text, ...) abort endif call add(items, item) endfor - if get(a:offsets, 0, 0) >= 0 + if get(a:offsets, 0, '') isnot# 'none' let items[-1].context = {'diff': items[0:-2]} - else - let item[-1].context = {} endif return [items[-1]] endfunction @@ -5544,7 +5542,7 @@ function! s:ToolParse(state, line) abort elseif a:line =~# '^\f\+:\d\+: \D' " --check let [_, to, line, text; __] = matchlist(a:line, '^\(\f\+\):\(\d\+\):\s*\(.*\)$') - return s:ToolItems(a:state, to, to, [-1, line], text) + return s:ToolItems(a:state, to, to, ['none', line], text) elseif a:state.mode !=# 'diffhead' && a:state.mode !=# 'hunk' && len(a:line) || a:line =~# '^git: \|^usage: \|^error: \|^fatal: ' return [{'text': a:line}] endif @@ -5599,7 +5597,7 @@ function! s:ToolStream(line1, line2, range, bang, mods, options, args, state) ab for item in s:ToolParse(a:state, line) if len(get(item, 'filename', '')) && item.filename != filename call add(cmd, 'tabedit ' . s:fnameescape(item.filename)) - for i in reverse(range(len(get(item.context, 'diff', [])))) + for i in reverse(range(len(get(get(item, 'context', {}), 'diff', [])))) call add(cmd, (i ? 'rightbelow' : 'leftabove') . ' vertical Gdiffsplit! ' . s:fnameescape(item.context.diff[i].filename)) endfor call add(cmd, 'wincmd =') -- 2.11.4.GIT