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. references.
g:CSApprox_redirfallback *g:CSApprox_redirfallback* g:CSApprox_redirfallback *g:CSApprox_redirfallback*
As of Vim 7.2.018, there is a bug in the Vim function synIDattr() that Until Vim 7.2.052, there was a bug in the Vim function synIDattr() that
stops it from correctly reporting information for the 'guisp' attribute. made it impossible to determine syntax information about the |guisp|
CSApprox includes a workaround for this problem, as well as a test that attribute. CSApprox includes a workaround for this problem, as well as a
ought to disable this workaround once synIDattr() is working properly. test that ought to disable this workaround if synIDattr() works properly.
If this test should happen to give improper results somehow, the user can 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 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* 4. Rationale/Design *csapprox-design*

View File

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