powerman/vim-plugin-AnsiEsc

conflict with lightline&airline: `AnsiEsc` breaking status line

Opened this issue · 2 comments

Calling :AnsiEsc one time works OK. Calling it a second time breaks the color of status line.

For the status line, I'm using lightline plugin. Also tried with airline and it also breaks

I've managed to reproduce the issue with following minimal vimrc

if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

call plug#begin('~/.vim/plugged')

Plug 'itchyny/lightline.vim'
Plug 'powerman/vim-plugin-AnsiEsc'

call plug#end()

set laststatus=2

Calling :AnsiEsc 2 times breaks the status bar on second call.

I don't use neither lightline nor airline and don't have enough spare time to research this conflict. If you'll manage to make a patch which didn't broke AnsiEsc and resolves this conflict please open a PR.

It is likely to happen in reloading AnsiEsc-ed buffer (not always, though).

It may break highlight groups.

" Open the log file to watch.
" Also set `autoreload`.
:e test.log
:setl noma ar
:AnsiEsc

" Run a terminal.
:vert below term
" Execute the commands below.
# Bash command.
# Output colored text, and dump it into `test.log`.
while true; do
    for (( i = 0; i <= 7; i++ )); do
        echo -en "\e[3${i}mhoge\e[m"
        sleep 0.1
    done
    echo ""
done | tee test.log

Then, switch the two window (i.e. Ctrl-w).

I confirmed it eventually resets some highlight groups such as Search.
I suppose it would also break highlight groups that the status-line plugins use.

This phenomenon happens while the command is running in a terminal.
Not likely to happen if the command is stopped.

Perhaps something is going bad in processing an on-going log.