zefei / vim-wintabs

Modern buffer manager for Vim
MIT License
325 stars 25 forks source link

When restoring from Vim session, buffers from other tabs are copied into the active tab #46

Open dylan-chong opened 5 years ago

dylan-chong commented 5 years ago
" Vim Session
" Settings to get it to work like vim-obsession (save session in current directory)
let g:session_autosave_silent = 1
let g:session_autoload = 'no'
let g:session_autosave = 'yes'
let g:session_lock_enabled = 0
let g:session_directory = './'
let g:session_default_name = 'Session'
let g:session_autosave_periodic = 0
let g:session_autosave_only_with_explicit_session = 1

" Win Tabs
let g:wintabs_ui_vimtab_name_format = '%t'
let g:wintabs_autoclose_vim = 1
let g:wintabs_autoclose_vimtab = 1
let g:wintabs_autoclose = 2
if !has('idea')
  " Change tabs
  nnoremap <Leader>gh gT
  nnoremap <Leader>g<Left> gT
  nnoremap <Leader>gl gt
  nnoremap <Leader>g<Right> gt

  " Change buffers
  nmap gh <Plug>(wintabs_previous)
  nmap g<Left> <Plug>(wintabs_previous)
  nmap gl <Plug>(wintabs_next)
  nmap g<Right> <Plug>(wintabs_next)

  " Other buffer stuff
  nmap <Leader>wu <Plug>(wintabs_undo)
  nmap <Leader>wm :WintabsMove<Space>
  nmap <Leader>wo <Plug>(wintabs_only)
  nnoremap <Leader>wO :tabonly<Bar>call<Space>wintabs#only()<Bar>only

  " Override q,q!,wq to avoid accidentally closing all of the buffers in the
  " tab
  function! SaveAndCloseCurrentBuffer()
    :up
    call wintabs#close()
  endfunction
  call CommandCabbr('q', 'call wintabs#close()')
  call CommandCabbr('q!', 'call wintabs#close()')
  call CommandCabbr('wq', 'call SaveAndCloseCurrentBuffer()')
endif
" Show git commit file in tabline
let g:wintabs_ignored_filetypes = []
autocmd FileType gitcommit set buflisted
" Fix this plugin overriding the styling for vim-airline
call g:Base16hi(
      \ 'TablineSel',
      \ g:base16_gui00,
      \ g:base16_gui0D,
      \ g:base16_cterm00,
      \ g:base16_cterm0D,
      \ 'bold',
      \ ''
      \ )
call g:Base16hi(
      \ 'Tabline',
      \ g:base16_gui04,
      \ g:base16_gui02,
      \ g:base16_cterm04,
      \ g:base16_cterm02,
      \ '',
      \ ''
      \ )
let g:wintabs_powerline_sep_buffer = ''
let g:wintabs_powerline_sep_tab = ''
" Reinitialise when reloading vimrc to make it look right
call wintabs_powerline#init()

Steps to reproduce the bug:

  1. Add the above code to your vimrc
  2. Run touch a b c; vim
  3. Inside Vim run :e a then :tabe b then :tabe c
  4. Save the session with :SaveSession
  5. :wqa
  6. Reopen Vim with the session vim -S

The session will load with the current files/configuration:

tab1
- a

tab2
- b

tab3
- c (active)
- a
- b

In the third tab, files a and b should not be there

zefei commented 5 years ago

Will investigate this soon, thank you for the repro!

zefei commented 5 years ago

Should be fixed in the latest commit.

dylan-chong commented 5 years ago

Thanks so much! I'll see how the fix goes!

On 6/01/2019, at 8:34 PM, Zefei Xuan notifications@github.com wrote:

Should be fixed in the latest commit.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.