Fix an important bug in CSApprox.

As reported by A. S. Budden, CSApprox caused the set GUI colors to be
overwritten when the cterm colors were set.  This happened because vim
attempts to reset some colors back to their defaults whenever the colors
for the Normal group change by calling syntax/syncolor.vim (I couldn't
find any documentation that explained this behavior).  The global
syncolor.vim allows any syncolor.vim before it in the runtimepath to
override its behavior by setting the variable g:syntax_cmd to something
not recognized, so I now work around this problem by doing exactly that
for the duration of the run.

See http://groups.google.com/group/vim_use/msg/2c6a7f5917f76057
This commit is contained in:
Matt Wozniski 2008-10-04 22:32:04 -04:00
parent 09e4f32e67
commit c0bd88e741

View File

@ -583,6 +583,14 @@ function! s:CSApprox()
unlet g:colors_name
endif
" Similarly, the global variable "syntax_cmd" must be set to something vim
" doesn't recognize, lest vim helpfully switch all colors back to the
" default whenever the Normal group is changed (in syncolor.vim)...
if exists("g:syntax_cmd")
let syntax_cmd = g:syntax_cmd
endif
let g:syntax_cmd = "PLEASE DON'T CHANGE ANY COLORS!!!"
" Set up our verbosity level, if needed.
" Default to 1, so the user can know if something's wrong.
if !exists("g:CSApprox_verbose_level")
@ -596,6 +604,11 @@ function! s:CSApprox()
let g:colors_name = colors_name
endif
unlet g:syntax_cmd
if exists("syntax_cmd")
let g:syntax_cmd = syntax_cmd
endif
let &lz = savelz
let &vbs = savevbs
endtry