aserebryakov / filestyle

filestyle is a Vim plugin that highlights unwanted whitespace and characters.

Home Page:http://www.vim.org/scripts/script.php?script_id=5065

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]: Errors when starting Vim in a narrow terminal

Markus00000 opened this issue · comments

Starting Vim in a narrow terminal with fewer than 40 columns produces these messages at startup and while editing:

FileStyle: ctermbg parameter should be defined explicitly
Press ENTER or type command to continue

Error detected while processing functio
n FileStyleActivate..FileStyleCheck..Fi
leStyleClearIgnoredPatters..FileStyleHi
ghlightPattern:
line    7:
E28: No such highlight group name: File
StyleIgnoredPattern
Error detected while processing functio
n FileStyleActivate..FileStyleCheck..Fi
leStyleClearBufferMatches:
line    3:
E802: Invalid ID: -1 (must be greater t
han or equal to 1)
Press ENTER or type command to continue

Error detected while processing functio
n FileStyleActivate..FileStyleCheck..Fi
leStyleClearIgnoredPatters..FileStyleHi
ghlightPattern:
line    7:
E28: No such highlight group name: File
StyleIgnoredPattern
Press ENTER or type command to continue

The first of all it looks like ctermbg was not defined in colorscheme.
Does running with wide terminal resolve the issue?

Yes, it is specific to terminals with fewer than 40 columns. No errors for wider terminals. It also happens with the default color scheme.

Can you reproduce it?

I succeed to reproduce the issue. As I can see, the issue can be caused by the following code:

redir => l:colors
silent highlight
redir END

let l:normal_start = match(l:colors, 'Normal\s\+xxx')
....
let l:normal_end = match(l:colors, '\n', l:normal_start)
let l:normal_group = l:colors[(l:normal_start):(l:normal_end)]

if (match(l:normal_group, 'ctermbg=') == -1)
  echom 'FileStyle: ctermbg parameter should be defined explicitly'
  return
endif

In case of narrow terminal, the Normal definition in highlight is longer than a single line, so it is needed to find more correct criteria of the definition ending.

The issue should be fixed by commit 3796757.

Fixed.

Sorry for necroing this issue, but this exact errors also happens when using the default colorscheme in vim (not gvim), as this default schema clears the Normal definition and so ctermbg is not defined.

@Juanitou Normal highlight group is required to support the ignored patterns.
Probably the better way is suppressing the feature instead of showing errors.

Thanks for your quick reply. I do not really understand what this feature is about. I hope you find a solution in your new milestone.

@Juanitou ignored patterns allows to specify the pattern that is not highlighted even if it violates some rules.

Thanks. As I continue to use the plugin, I hope to help you find a better solution than simply removing the feature.

Thanks!