Sunday, October 11, 2015

slow display update, maybe due to folded text

I have the following function that flashes crosshairs in the current
window so that my attention gets brought to where the active window
is, and where the cursor is. It has received many contributions from
this vim group, for I thank the contributors.

function FlashLocn()
let g:curwin = winnr()
windo let w:oldcurline=&cursorline
windo let w:oldcurcol=&cursorcolumn
windo setl nocursorline nocursorcolumn
exec g:curwin.'wincmd w'
let tmpCuL=&cul
let tmpCuC=&cuc
let tmpHiCuL = Hi("CursorLine")
let tmpHiCuC = Hi("CursorColumn")
hi CursorLine guibg=white guifg=black
hi CursorColumn guibg=white guifg=black
setl cul cuc
redraw
sleep 150m
hi CursorLine NONE
hi CursorColumn NONE
exe tmpHiCuL
exe tmpHiCuC
let &cursorline=tmpCuL
let &cursorcolumn=tmpCuC
windo let &cursorline=w:oldcurline
windo let &cursorcolumn=w:oldcurcol
exec g:curwin.'wincmd w'
endfunction

It works by storing the number of windows in g:curwin, and saving the
state of cursorline & cursorcolumn for each window before disabling
those options. Then it switches to the current window by iterative
execution of 'windmc w'. In the current window, it saves cursorline,
cursorline, and their highlighting colours, changes them to white, and
enables them for 150ms. Then it cleans up before exiting by restoring
cursorline, cursorcolumn, and their hightlighting colours.

I'm finding that if I have a window with many closed folds, *and* I
have another window containing a different file, then the 150ms is
more like a full second. I'm assuming that vim is going through all the
folded lines in order to update the display. It's very annoying when
I work with many windows. Is there an (uncomplicated) way to
ameliorate this problem?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: