Mercurial > vim
comparison src/testdir/test_gui.vim @ 30011:b8abb8908801 v9.0.0343
patch 9.0.0343: ColorScheme autocommand triggered when colorscheme not found
Commit: https://github.com/vim/vim/commit/5d09a401ec393dc930e1104ceb38eab34681de64
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Aug 31 21:17:10 2022 +0100
patch 9.0.0343: ColorScheme autocommand triggered when colorscheme not found
Problem: ColorScheme autocommand triggered when colorscheme is not found.
(Romain Lafourcade)
Solution: Only trigger ColorScheme when loading the colorscheme succeeds.
(closes #11024)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 31 Aug 2022 22:30:06 +0200 |
parents | d891115c0aea |
children | 9735b6186254 |
comparison
equal
deleted
inserted
replaced
30010:0379de231ecd | 30011:b8abb8908801 |
---|---|
34 | 34 |
35 let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default' | 35 let colorscheme_saved = exists('g:colors_name') ? g:colors_name : 'default' |
36 let g:color_count = 0 | 36 let g:color_count = 0 |
37 augroup TestColors | 37 augroup TestColors |
38 au! | 38 au! |
39 au ColorScheme * let g:color_count += 1| let g:after_colors = g:color_count | 39 au ColorScheme * let g:color_count += 1 |
40 au ColorSchemePre * let g:color_count += 1 |let g:before_colors = g:color_count | 40 \ | let g:after_colors = g:color_count |
41 \ | let g:color_after = expand('<amatch>') | |
42 au ColorSchemePre * let g:color_count += 1 | |
43 \ | let g:before_colors = g:color_count | |
44 \ | let g:color_pre = expand('<amatch>') | |
41 augroup END | 45 augroup END |
42 | 46 |
43 colorscheme torte | 47 colorscheme torte |
44 redraw! | 48 redraw! |
45 call assert_equal('dark', &background) | 49 call assert_equal('dark', &background) |
46 call assert_equal(1, g:before_colors) | 50 call assert_equal(1, g:before_colors) |
47 call assert_equal(2, g:after_colors) | 51 call assert_equal(2, g:after_colors) |
52 call assert_equal('torte', g:color_pre) | |
53 call assert_equal('torte', g:color_after) | |
48 call assert_equal("\ntorte", execute('colorscheme')) | 54 call assert_equal("\ntorte", execute('colorscheme')) |
49 | 55 |
50 let a = substitute(execute('hi Search'), "\n\\s\\+", ' ', 'g') | 56 let a = substitute(execute('hi Search'), "\n\\s\\+", ' ', 'g') |
51 " FIXME: temporarily check less while the colorscheme changes | 57 " FIXME: temporarily check less while the colorscheme changes |
52 " call assert_match("\nSearch xxx term=reverse cterm=reverse ctermfg=196 ctermbg=16 gui=reverse guifg=#ff0000 guibg=#000000", a) | 58 " call assert_match("\nSearch xxx term=reverse cterm=reverse ctermfg=196 ctermbg=16 gui=reverse guifg=#ff0000 guibg=#000000", a) |
53 call assert_match("\nSearch xxx term=reverse ", a) | 59 call assert_match("\nSearch xxx term=reverse ", a) |
54 | 60 |
55 call assert_fails('colorscheme does_not_exist', 'E185:') | 61 call assert_fails('colorscheme does_not_exist', 'E185:') |
62 call assert_equal('does_not_exist', g:color_pre) | |
63 call assert_equal('torte', g:color_after) | |
56 | 64 |
57 exec 'colorscheme' colorscheme_saved | 65 exec 'colorscheme' colorscheme_saved |
58 augroup TestColors | 66 augroup TestColors |
59 au! | 67 au! |
60 augroup END | 68 augroup END |