Open oblitum opened 8 years ago
It also activates on reaching a given window. It's a bit funny :-) but distracting.
There's another issue related to this, which I still didn't get the time to pin down for reporting as another issue, which happens when I zoom windows in and out and move between them. I use drn/zoomwin-vim to zoom a given window in focus. In this context I get a bunch of color_coded errors when zooming out a window that I've zoomed in:
Error detected while processing function color_coded#enter..color_coded#clear_matches:
line 3:
E803: ID not found: 3314
E803: ID not found: 3315
E803: ID not found: 3316
E803: ID not found: 3317
E803: ID not found: 3318
E803: ID not found: 3319
E803: ID not found: 3320
E803: ID not found: 3321
E803: ID not found: 3322
E803: ID not found: 3323
E803: ID not found: 3324
E803: ID not found: 3325
E803: ID not found: 3326
E803: ID not found: 3327
E803: ID not found: 3328
E803: ID not found: 3329
E803: ID not found: 3330
E803: ID not found: 3331
E803: ID not found: 3332
E803: ID not found: 3333
E803: ID not found: 3334
E803: ID not found: 3335
E803: ID not found: 3336
E803: ID not found: 3337
E803: ID not found: 3338
E803: ID not found: 3339
E803: ID not found: 3340
E803: ID not found: 3341
E803: ID not found: 3342
E803: ID not found: 3343
E803: ID not found: 3344
E803: ID not found: 3345
E803: ID not found: 3346
E803: ID not found: 3347
E803: ID not found: 3348
E803: ID not found: 3349
E803: ID not found: 3350
E803: ID not found: 3351
E803: ID not found: 3352
E803: ID not found: 3353
E803: ID not found: 3354
E803: ID not found: 3355
E803: ID not found: 3356
E803: ID not found: 3357
E803: ID not found: 3358
E803: ID not found: 3359
E803: ID not found: 3360
E803: ID not found: 3361
E803: ID not found: 3362
E803: ID not found: 3363
E803: ID not found: 3364
E803: ID not found: 3365
After the previous error happen, the highlighting state inside the window doesn't update, even after :CCtoggle
s.
On Mon, Oct 19, 2015 at 09:00:46AM -0700, Francisco Lopes wrote:
There's another issue related to this which I still didn't get the time to pin down for reporting as another issue which happens when I zoom windows in and out and move between them. I use [1]drn/zoomwin-vim to zoom a given window in focus. In this context I get a bunch of color_coded errors when zooming out a window:
I can imagine why this would happen. Due to vim's slow highlighting, color_coded keeps track of what's currently visible in each window (not buffer); it ties into key vim events to learn when it needs to adjust the highlighted range. If you're zooming in/out, you'll need to call color_coded#moved
whenever that happens.
I can't look at that plugin right now, so I'm not sure which events it's using or how one can plug in extra functionality. However, a call to color_coded#moved
should be all that's needed. If you haven't found anything by tomorrow (it's late for me), I can take a look.
On Mon, Oct 19, 2015 at 08:33:46AM -0700, Francisco Lopes wrote:
Using :sp to have two windows and switching through them deactivates color_coded for the code in the window being left.
That was the case with the old implementation and it was changed just a couple of days ago. Please make sure you're on the tip of master and let me know if it's still happening.
I'm on tip.
I'm on Ubuntu now, if any other information is needed to reproduce it, in case you coudn't, just let me know.
I've setup the following for the zoomwin plugin in my .vimrc
:
function! s:zoom_win_callback(state)
call color_coded#moved()
endfunction
if !exists("g:ZoomWin_funcref")
let g:ZoomWin_funcref = function("s:zoom_win_callback")
endif
But I guess this may also be an issue with other plugins like junegunn/goyo and related.
Also, even though I've setup that, I still get the same errors.
Alright, let's do this. Do you mind taking the time to setup a sample (gist or repo or link to repo with a proper .color_coded) which shows the primary issue here (:sp
color deactivation when toggling)? I'm not able to reproduce the issue, so far.
Next, to handle the other issue, will you confirm with my your zoomwin config (so I can duplicate it) and also the sources in which this has been an issue (would be great if it's the same source from above).
I can reproduce both issues on Arch with the following minimal .vimrc
:
" VIM-PLUG Setup {{{
" Automatic installation {{{
if empty(glob('~/.vim/autoload/plug.vim'))
silent !mkdir -p ~/.vim/autoload
silent !curl -fLo ~/.vim/autoload/plug.vim
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
au VimEnter * PlugInstall
endif
" }}}
call plug#begin('~/.vim/plugged')
" Plugins {{{
Plug 'tpope/vim-sensible'
Plug 'romainl/Apprentice'
Plug 'jeaye/color_coded', { 'do': 'cmake . && make && make install' }
Plug 'drn/zoomwin-vim'
" }}}
call plug#end()
" Plugin Preloading {{{
runtime! plugin/sensible.vim
" }}}
" }}}
" Colorscheme {{{
colors apprentice
" }}}
Using the given two sample files,
sample1.cpp
, sample2.cpp
:
#include <iostream>
using namespace std;
int main() {
}
You can open these two identical c++ files with split windows and switch back and forth between the windows, color_coded will toogle on and off when leaving a given window.
If I zoom in a given window with :ZoomWin
, and then zoom out (:ZoomWin
again), and then switch to another window, a get the error list at the moment I switch.
I'm not using any .color_coded
for this setup.
Hm, I get an odd error when zooming out with ^Wo
:
Error detected while processing function ZoomWin#ZoomWin..<SNR>97_RestoreWinVars:
line 3:
E474: Invalid argument
Are you also seeing this?
Now, as far as the original issue goes. Yes, I can reproduce it; this is intended behavior. When you :sp
(or :vsp
) the same file, this doesn't happen, since BufLeave
isn't sent off. However, if you're switching between splits of different files, color_coded intentionally clears all matches whenever it leaves a window.
This relates to #9, which you also created. As far as I know, this needs to remain for now. The related source is: https://github.com/jeaye/color_coded/blob/master/plugin/color_coded.vim#L59
Back to the zooming issue: I am able to reproduce the invalid ID errors, but I'm also getting the zooming error mentioned above, which may be playing into it. Until I can get that resolved, I can't really be certain that they're unrelated. The actual source of the issues is color_coded trying to clear some previous matches which no longer exist. I can think of a possible fix for it and I'll make a branch for you today, assuming we can resolve this zooming error.
Your ZoomWin error is not reproducible for me, I've never seen this issue on Ubuntu/Arch/OS X...
By the way, I'm not trying to use the ZoomWin callback anymore, in case you're relying on it.
On Tue, Oct 20, 2015 at 05:22:42AM -0700, Francisco Lopes wrote:
By the way, I'm not trying to use the ZoomWin callback anymore, in case you're relying on it.
Nope, I'm not using it. Just normal ZoomWin. I'll give it another look today.
I have been able to reproduce the error in your setup on my Arch machine. It wasn't showing up on my Slackware machine. I'm looking into it now.
The logic behind vim's event systems and what's valid at which point (during most events, only half of what color_coded uses per-buffer and per-window is available -- it needs to cache quite a bit) makes this a very difficult issue to solve. Being able to properly handle multiple buffers, windows, where windows may be showing the same or different buffers, has been an ongoing struggle.
I've given this half a dozen attempts over the past several months and I haven't been able to iron out every edge case yet. This ZoomWin issue is one of them.
I've added a try/catch around this common pain point. While it doesn't resolve the issue, it means that color_coded will be less annoying (with all the red text and errors) when this happens.
Better than nothing :-)
Will try it when I can.
Not getting this error anymore.
Ops. Reopening. Not getting the ZoomWin error anymore. Window switching is still an issue.
Same error, can get very annoying:
It works if I cclose inside the quickfix window. It does not work if I do a "copen | cclose" in the editor window. My workaround for now is to use "only" instead of cclose, but that will fail inside the quickflix window.
Using
:sp
to have two windows and switching through them deactivates color_coded for the code in the window being left.