Code Monkey home page Code Monkey logo

Comments (4)

jordwalke avatar jordwalke commented on August 13, 2024 1

Related, you cannot even close any non-named buffer without raising this error (try :enew). One helpful datapoint: If before deleting the non-named buffer, you set :setlocal bufhidden=hide then the error doesn't happen. I think it's because with bufhidden=delete (or even the default value of empty string) the buffer is deleted twice - once by default and once by wintabs. But bufhidden=hide it doesn't fully delete the buffer when wintabs tries to remove it after modifying the unnamed buffer.

from vim-wintabs.

zefei avatar zefei commented on August 13, 2024

Thanks for flagging this! Will fix it soonish.

from vim-wintabs.

jordwalke avatar jordwalke commented on August 13, 2024

And with the following config:

let g:wintabs_display='statusline'
set hidden
let g:wintabs_autoclose=2
let g:wintabs_autoclose_vim=1
let g:wintabs_autoclose_vimtab=1
let g:wintabs_switchbuf='useopen,usetab'
let g:wintabs_ui_active_higroup = 'TabLineSel'

As mentioned in the initial description closing the first/only non-named modified buffer works.

But then with that new config, closing the first/only named buffer does not work if you have modifications.

In this case, I think the problem is this function which is called before bdelete on the unnamed buffer.

function! s:switch_tab(n, confirm)
  " do nothing if n >= size
  if a:n >= len(w:wintabs_buflist)
    return
  endif

  " set nohidden to trigger confirm behavior
  let hidden = &hidden
  let &hidden = 0

  if a:n < 0
    execute a:confirm ? 'silent! confirm enew' : 'enew!'
  else
    let buffer = w:wintabs_buflist[a:n]
    execute a:confirm ? 'silent! confirm buffer '.buffer : 'buffer! '.buffer
  endif

  " restore hidden
  let &hidden = hidden
endfunction

which is called before "purge"ing the unnamed buffer via bdelete.
The silent! confirm buffer switches to another tab, and since nohidden is set on the unnamed buffer it is deleted. Then when you later try to bdelete it it's already gone.

This is actually hard to get right because you rely on the tab switching function to trigger the confirmation if the buffer does happen to implicitly hidden when switching away from it and if it's not displayed in any other window. I think you might just be able to get away with not ever purging. This seems to restore proper functionality from what I can tell by testing. I think what you can do after any interaction, is to examine what the end result was - which buffers ended up being completely unloaded wintabs, yet remained listed by vim - and then only purge those, instead of trying to predict which buffer number must be purged based on the interaction at hand. You can instead inspect what Vim sees at the end of each interaction and purge according to that.

Simply commenting out the bdelete line works well - the UI is always up to date, and there's no errors. The only downside is that there's some useless buffers listed in buffers. Seems better than having errors though.

from vim-wintabs.

zefei avatar zefei commented on August 13, 2024

This should be fixed now. Thank you for the analysis @jordwalke, it helped me resolve another issue. Some of the edge cases we see here are indeed caused by wintab's reliance on the interaction between "confirm" and "hidden".

Due to the recent vim changes on "silent!"+"confirm", I'm not very sure if I'm fixing the right thing (I removed some "silent!" to bubble up exceptions). Please test out the new version and let me know if things still behave correctly and consistently.

from vim-wintabs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.