[vim/vim] The ColorScheme event works in unexpected ways (Issue #11024)

48 views
Skip to first unread message

Romain Lafourcade

unread,
Aug 31, 2022, 3:41:24 PM8/31/22
to vim/vim, Subscribed

Steps to reproduce

  1. Start Vim with $ vim --clean.

  2. Run the following command:

    :autocmd! ColorScheme * echomsg '<amatch>: ' . expand('<amatch>') . ' g:colors_name: ' . g:colors_name
    
  3. Change to an existing colorscheme:

    :color desert
    
  4. Do :mess to see the message:

    <amatch>: desert g:colors_name: desert
    
  5. Change to a non-existing colorscheme:

    :color hsgdyourtd
    
  6. Get unexpected message and expected error:

    <amatch>: hsgdyourtd g:colors_name: desert                                                                                       
    E185: Cannot find color scheme 'hsgdyourtd'
    Press ENTER or type command to continue
    

Expected behaviour

I would expect the autocommand to not be triggered.


:help ColorScheme says:

After loading a color scheme. |:colorscheme| The pattern is matched against the colorscheme name. <afile> can be used for the name of the actual file where this option was set, and <amatch> for the new colorscheme name.

  • The colorscheme hasn't been loaded so it didn't change g:colors_name and there is no "colorscheme name" to speak of, so <amatch> shouldn't have the value of the :colorscheme argument.
  • Since the non-existing colorscheme hasn't been loaded, the event shouldn't fire to begin with.

Version of Vim

All

Environment

Irrelevant

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11024@github.com>

Bram Moolenaar

unread,
Aug 31, 2022, 4:18:05 PM8/31/22
to vim/vim, Subscribed

Closed #11024 as completed via 5d09a40.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/11024/issue_event/7299449036@github.com>

Reply all
Reply to author
Forward
0 new messages