chrisbra / Recover.vim

A Plugin to show a diff, whenever recovering a buffer
http://www.vim.org/scripts/script.php?script_id=3068
248 stars 25 forks source link

bad behaviour with Powerline #3

Closed lyokha closed 12 years ago

lyokha commented 12 years ago

Hi.

Nice plugin! Only i found that it breaks Powerline status line when :FinishRecovery issued. The problem arises from s:ModifySTL() when argument enable is 0. Actually it tries to restore &stl from value of s:ostl - but this value, created upon plugin's start has nothing to do with value of &stl on :FinishRecovery moment if Powerline is installed - Powerline just changes it to something like %!Pl#Statusline(0,1) and restoring &stl from older s:ostl breaks Powerline status line.

Some workaround could be: store also new value of &stl in variable, say, s:nstl and then, when restoring &stl, check if it changed - if it changed (e.g. By Powerline) then just do nothing.

fu! s:ModifySTL(enable) "{{{1 if a:enable " Inject some info into the statusline :let s:ostl=&stl :let s:nstl=substitute(&stl, '%f', "\0 %{exists('b:mod')?('['.b:mod.']') : ''}", 'g') :let stl=s:nstl else " Restore old statusline setting if exists("s:ostl") && s:nstl == &stl let &stl=s:ostl endif endif endfu

This workaround won't break old behaviour and will fix the issue with Powerline (it works for me).

chrisbra commented 12 years ago

On Mon, March 26, 2012 16:15, lyokha wrote:

Hi.

Nice plugin! Only i found that it breaks Powerline status line when :FinishRecovery issued. The problem arises from s:ModifySTL() when argument enable is 0. Actually it tries to restore &stl from value of s:ostl - but this value, created upon plugin's start has nothing to do with value of &stl on :FinishRecovery moment if Powerline is installed - Powerline just changes it to something like %!Pl#Statusline(0,1) and restoring &stl from older s:ostl breaks Powerline status line.

Some workaround could be: store also new value of &stl in variable, say, s:nstl and then, when restoring &stl, check if it changed - if it changed (e.g. By Powerline) then just do nothing.

fu! s:ModifySTL(enable) "{{{1 if a:enable " Inject some info into the statusline :let s:ostl=&stl :let s:nstl=substitute(&stl, '%f', "\0 %{exists('b:mod')?('['.b:mod.']') : ''}", 'g') :let stl=s:nstl else " Restore old statusline setting if exists("s:ostl") && s:nstl == &stl let &stl=s:ostl endif endif endfu

This workaround won't break old behaviour and will fix the issue with Powerline (it works for me).

Thanks for your feedback. Looks good and I'll include it.

regards, Christian

lyokha commented 12 years ago

Sorry, there is a typo, printed

:let stl=s:nstl

must be

:let &stl=s:nstl