Skip to content

Commit

Permalink
Don't set foldmethod=syntax in historical buffers
Browse files Browse the repository at this point in the history
This was originally implemented in part to address the marker fold
method triggering on diffs, so try to still solve that.
  • Loading branch information
tpope committed Mar 24, 2021
1 parent 133bf40 commit 156dbcd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion autoload/fugitive.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,9 @@ function! fugitive#BufReadCmd(...) abort
setlocal endofline

try
if &foldmethod ==# 'marker' && b:fugitive_type !=# 'blob'
setlocal foldmethod=manual
endif
silent exe s:DoAutocmd('BufReadPre')
if b:fugitive_type ==# 'tree'
let b:fugitive_display_format = b:fugitive_display_format % 2
Expand Down Expand Up @@ -2233,7 +2236,7 @@ function! fugitive#BufReadCmd(...) abort
endif
let &l:modifiable = modifiable
if b:fugitive_type !=# 'blob'
setlocal filetype=git foldmethod=syntax
setlocal filetype=git
call s:Map('n', 'a', ":<C-U>let b:fugitive_display_format += v:count1<Bar>exe fugitive#BufReadCmd(@%)<CR>", '<silent>')
call s:Map('n', 'i', ":<C-U>let b:fugitive_display_format -= v:count1<Bar>exe fugitive#BufReadCmd(@%)<CR>", '<silent>')
endif
Expand Down

2 comments on commit 156dbcd

@ytian81
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folding in historical buffer is pretty useful for my use cases. So I am wondering if this change is permanent or not? If so, I'd like to add foldmethod=syntax on my own for git filetype.

@tpope
Copy link
Owner Author

@tpope tpope commented on 156dbcd Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's most likely permanent. Syntax folding is just plain too slow to force as a default on everyone. So yeah, go ahead and set it in after/ftplugin/git.vim if you want to keep using it.

Please sign in to comment.