Update CSApprox now that synIDattr supports guisp

Docs are updated to reference the required patch number (7.2.052) and
the code is updated to test based on the existence of that patch, rather
than brute forcing.
This commit is contained in:
Matt Wozniski 2008-12-02 04:36:11 -05:00
parent e7db246c9d
commit 147d3c9f71
2 changed files with 14 additions and 22 deletions

View File

@ -188,13 +188,15 @@ g:CSApprox_approximator_function *g:CSApprox_approximator_function*
references.
g:CSApprox_redirfallback *g:CSApprox_redirfallback*
As of Vim 7.2.018, there is a bug in the Vim function synIDattr() that
stops it from correctly reporting information for the 'guisp' attribute.
CSApprox includes a workaround for this problem, as well as a test that
ought to disable this workaround once synIDattr() is working properly.
Until Vim 7.2.052, there was a bug in the Vim function synIDattr() that
made it impossible to determine syntax information about the |guisp|
attribute. CSApprox includes a workaround for this problem, as well as a
test that ought to disable this workaround if synIDattr() works properly.
If this test should happen to give improper results somehow, the user can
force the behavior with this variable. When set to 1, the workaround will
always be used, and when set to 0, synIDattr() is blindly used.
always be used, and when set to 0, synIDattr() is blindly used. Needless
to say, if this automatic detection should ever fail, the author would
like to be notified!
==============================================================================
4. Rationale/Design *csapprox-design*

View File

@ -149,25 +149,15 @@ endfunction
" {>1} Collect info for the set highlights
" {>2} Determine if synIDattr is usable
" As of 7.2.018, synIDattr() can't be used to check 'guisp', and no official
" patch has been released despite my suggesting one. So, in an attempt to be
" forward compatible, I've included a test to see if synIDattr() works
" properly. If synIDattr() works properly, we'll use it to check the 'guisp'
" attribute, otherwise we'll fall back onto using :redir and checking the
" output of :highlight. This test can be overridden by setting the global
" variable g:CSApprox_redirfallback to 1 (to force use of :redir) or to 0 (to
" force use of synIDattr()).
" synIDattr() couldn't support 'guisp' until 7.2.052. This function returns
" true if :redir is needed to find the 'guisp' attribute, false if synIDattr()
" is functional. This test can be overridden by setting the global variable
" g:CSApprox_redirfallback to 1 (to force use of :redir) or to 0 (to force use
" of synIDattr()).
function! s:NeedRedirFallback()
if !exists("g:CSApprox_redirfallback")
hi CSApproxTest guisp=Red gui=standout
if synIDattr(hlID('CSApproxTest'), 'sp', 'gui') == '1'
" We requested the 'sp' attribute, but vim thought we wanted 'standout'
" So, reporting of the guisp attribute is broken. Fall back on :redir
let g:CSApprox_redirfallback=1
else
" Reporting guisp works, use synIDattr
let g:CSApprox_redirfallback=0
endif
let g:CSApprox_redirfallback = (v:version == 702 && !has('patch52'))
\ || v:version < 702
endif
return g:CSApprox_redirfallback
endfunction