Skip to content

Commit

Permalink
Run diffthis before editing files to avoid foldmethod problem
Browse files Browse the repository at this point in the history
If `foldmethod=syntax` it somehow affects the contents the deletes will
operate on. No idea why. Running `diffthis` will set `foldmethod=diff`
so if we do that before making the edits we should avoid the problem.

Closes #28
  • Loading branch information
whiteinge committed Jan 29, 2024
1 parent 05e8d2e commit 8f21226
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plugin/diffconflicts.vim
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@ function! s:diffconfl()
1delete
silent execute "file RCONFL"
silent execute "set filetype=". l:origFt
diffthis " set foldmethod before editing
silent execute "g/^<<<<<<< /,/^=======\\r\\?$/d"
silent execute "g/^>>>>>>> /d"
setlocal nomodifiable readonly buftype=nofile bufhidden=delete nobuflisted
diffthis

" Set up the left-hand side.
wincmd p
diffthis " set foldmethod before editing
if l:conflictStyle ==? "diff3" || l:conflictStyle ==? "zdiff3"
silent execute "g/^||||||| \\?/,/^>>>>>>> /d"
else
silent execute "g/^=======\\r\\?$/,/^>>>>>>> /d"
endif
silent execute "g/^<<<<<<< /d"
diffthis

diffupdate
endfunction

function! s:showHistory()
Expand Down

0 comments on commit 8f21226

Please sign in to comment.