dwm.vim icon indicating copy to clipboard operation
dwm.vim copied to clipboard

When loading session dwm changes buffers in windows past the third window

Open count-ellington opened this issue 4 years ago • 1 comments

If you load a previous session saved with a layout from the dwm plugin that looks like this


=====================================
|              |        B           | 
|              |====================|
|      A       |        C           | 
|              |====================|
|              |        D           | 
=====================================

Each window, past the third will be a copy of the third window, and the buffers will be rotated so that whatever buffer was last is now master, the second to last is now second and Master is now in the third slot Like below

=====================================
|              |        C           | 
|              |====================|
|      D       |        A           | 
|              |====================|
|              |        A           | 
=====================================

The buffer B will still be in the bufferlist but it will no longer be open in a window.

This is something that happens on the loading of the session. If the session is loaded without plugins you can see that it will load correctly. I also tested this with no other plugins besides vim-plug and dwm active and the problem persists.

count-ellington avatar Jul 10 '20 14:07 count-ellington

I actually figured out a solution. The dwm autocommand needs to be toggled off when a session is being loaded and then turned back on when the session is done being loaded. The following can be accomplished by adding this to the bottom of the code.

function! ToggleDwmAutogroup()
	if !exists('#dwm#BufWinEnter')
		augroup dwm
			au!
			au BufWinEnter * if &l:buflisted || &l:filetype == 'help' | call DWM_AutoEnter() | endif
		augroup end
	else
		augroup dwm
			au!
		augroup end
	endif
endfunction

au VimEnter * au SourcePre * call ToggleDwmAutogroup()
au VimEnter * au SourcePost * call ToggleDwmAutogroup()

An alternate solution, which I didn't see until I began typing this comment is to use the pull request from delphinus but change it from a buffer variable to a global variable (that is change b: to g:) and do the let command instead of calling the function.

count-ellington avatar Jul 17 '20 22:07 count-ellington