kwin-scripts / kwin-tiling

Tiling script for kwin
GNU General Public License v2.0
1.1k stars 68 forks source link

gvimdiff buffer window proportions #174

Closed jflorian closed 5 years ago

jflorian commented 5 years ago

I'm seeing an issue that looks to be a race condition and am trying to figure out a kludge of sorts to resolve it. When gvimdiff creates a new window, it attempts to give each buffer an equal portion of the overall window. This division seems to usually occur before kwin-tiling sets the size so the buffer proportions are derived from a maximal-sized window then kwin-tiling does its sizing, likely making the gvimdiff window smaller to tile it and thus the buffer proportions are all off. In some rare cases kwin-tiling gets there first and then buffer proportions are equal.

If they're unequal, I can give vim a ^w= command to correct them but am hoping for a solution where this is unnecessary. I've tried the following in my vimrc but this doesn't help because it executes before the window is drawn:

if &diff == 1
    sleep 3
    redraw!
    execute "normal! ^w="
endif

The sleep and redraw are attempts to crudely rig the race but these actually cause the contents to be drawn on the konsole window from which I'm launching gvim and this still happens before the window appears. In essence, the sleep only further delays the window creation.

faho commented 5 years ago

Try the "VimResized" autocmd, like

autocmd VimResized * wincmd =

in your vimrc.

That's the proper solution, because there's no way for us to resize any earlier.

(via https://vi.stackexchange.com/questions/201/make-panes-resize-when-host-window-is-resized)

jflorian commented 5 years ago

Beautiful! That works like a charm. Thanks so much for the super fast response.