]> git.wincent.com - pinnacle.git/commit
refactor: drop "silent" from capture_highlight call
authorGreg Hurrell <greg@hurrell.net>
Tue, 13 Oct 2020 19:23:58 +0000 (21:23 +0200)
committerGreg Hurrell <greg@hurrell.net>
Tue, 13 Oct 2020 19:29:21 +0000 (21:29 +0200)
commit9b7f71ec2242c005af89f8d7a8aa7c7e9bfbaa25
tree0a4188a54ccc7fe02a0c55e57216755ac1a11a48
parentc7ca2b8b8aaf564fc80abbdc17d17cafbe53e5fc
refactor: drop "silent" from capture_highlight call

This was needed historically, but I thought it might be causing
inconsistent behavior nowadays.

I was seeing errors in Corpus if I activated it too soon after opening
Vim (no errors if I waited though).

    Error detected while processing function <SNR>106_CheckColorScheme:
    E5108: Error executing lua ...g/nvim/pack/bundle/opt/pinnacle/lua/wincent/pinnacle.lua:25: attempt to index local 'original' (a nil value)
    E416: missing equal sign: 0
    E416: missing equal sign: null

(Many of these, but those show the basic patterns.)

Adding some debug info, I could see that the `:hi` command we were
trying to use was returning empty strings for some of the groups:

    {
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "MatchParen:  MatchParen     xxx ctermbg=8 guibg=#585858",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "Comment:     Comment        xxx ctermfg=8 guifg=#585858",
      "DiffText:    DiffText       xxx cterm=bold ctermfg=4 ctermbg=10 gui=bold guifg=#7cafc2 guibg=#282828",
      "ModeMsg:     ModeMsg        xxx cterm=bold ctermfg=2 gui=bold guifg=#a1b56c",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "MatchParen:  MatchParen     xxx ctermbg=8 guibg=#585858",
      "StatusLine:  StatusLine     xxx ctermfg=12 ctermbg=11 guifg=#b8b8b8 guibg=#383838",
      "Comment:",
      "DiffText:",
      "ModeMsg:",
      "StatusLine:",
      "PmenuSel:",
      "Underlined:",
      "ModeMsg:"
    }

So, this explains the errors. Our `capture_highlight` call is
occasionally getting an empty string back. Subsequent attempts to match
a pattern in the string fail, leading to a `nil` return on the Lua side
and a `null` coercion on the Vim side. I have no idea why the first few
calls all work fine and subsequent calls, even for groups like `ModeMsg`
that previously worked, do not.

In this commit I drop the `silent` in an effort to make the errors go
away. It doesn't work (we're still getting empty strings), but it does
show that we don't need the silent any more, so let's just go with it
and keep exploring.
lua/wincent/pinnacle.lua