Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2b65834

Browse files
committedFeb 15, 2017
made LinediffMerge & LinediffPick work
1 parent cf273ee commit 2b65834

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed
 

‎autoload/linediff.vim

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ endfunction
3434

3535
function! linediff#LinediffReset(bang)
3636
let force = a:bang == '!'
37+
augroup LinediffAug
38+
autocmd!
39+
augroup END
3740
for dfr in s:differ
3841
call dfr.CloseAndReset(force)
3942
endfor
@@ -48,7 +51,7 @@ function! linediff#LinediffMerge()
4851
endif
4952

5053
let [top_area, bottom_area] = areas
51-
let [mfrom, mto] = [top_area[0]-1, bottom_area[1]+1]
54+
let [mfrom, mto] = [top_area[0] - 1, bottom_area[1] + 1]
5255

5356
call linediff#Linediff(top_area[0], top_area[1], {'is_merge': 1, 'merge_from': mfrom, 'merge_to': mto, 'label': top_area[2]})
5457
call linediff#Linediff(bottom_area[0], bottom_area[1], {'is_merge': 1, 'merge_from': mfrom, 'merge_to': mto, 'label': bottom_area[2]})
@@ -81,6 +84,7 @@ function! s:PerformDiff()
8184
let &diffopt = g:linediff_diffopt
8285
endif
8386

87+
augroup LinediffAug
8488
call s:differ[0].CreateDiffBuffer(g:linediff_first_buffer_command)
8589
autocmd BufUnload <buffer> silent call linediff#LinediffReset('')
8690

@@ -89,6 +93,7 @@ function! s:PerformDiff()
8993
call dfr.CreateDiffBuffer(g:linediff_further_buffer_command)
9094
autocmd BufUnload <buffer> silent call linediff#LinediffReset('')
9195
endfor
96+
augroup END
9297

9398
let l:swb_old = &switchbuf
9499
set switchbuf=useopen,usetab

‎autoload/linediff/differ.vim

+10-9
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ function! linediff#differ#Init(from, to, options) dict
5050
let self.from = a:from
5151
let self.to = a:to
5252

53-
if has_key(a:options, 'is_merge')
54-
let self.is_merge = a:options.is_merge
55-
endif
56-
57-
if has_key(a:options, 'label')
58-
let self.label = a:options.label
59-
endif
53+
for k in keys(a:options)
54+
if has_key(self, k)
55+
let self[k] = a:options[k]
56+
endif
57+
endfor
6058

6159
call self.SetupSigns()
6260

@@ -187,13 +185,13 @@ function! linediff#differ#SetupDiffBuffer() dict
187185
exe "set filetype=" . self.filetype
188186
setlocal bufhidden=wipe
189187

190-
autocmd BufWrite <buffer> silent call b:differ.UpdateOriginalBuffer()
188+
autocmd LinediffAug BufWrite <buffer> silent call b:differ.UpdateOriginalBuffer()
191189
else " g:linediff_buffer_type == 'scratch'
192190
silent exec 'keepalt file ' . escape(description, '[ ')
193191
exe "set filetype=" . self.filetype
194192
set nomodified
195193

196-
autocmd BufWriteCmd <buffer> silent call b:differ.UpdateOriginalBuffer()
194+
autocmd LinediffAug BufWriteCmd <buffer> silent call b:differ.UpdateOriginalBuffer()
197195
endif
198196
endfunction
199197

@@ -271,6 +269,9 @@ function! linediff#differ#UpdateOtherDiffer(delta, other) dict
271269

272270
call a:other.SetupSigns()
273271
endif
272+
if self.is_merge && a:other.is_merge
273+
let a:other.merge_to = a:other.merge_to + a:delta
274+
endif
274275
endfunction
275276

276277
" Was this buffer created from a merge area?

0 commit comments

Comments
 (0)