Sublime Forum

Closing tabs with changes w/out asking if tab is duplicate

#1

I’d like to be able to close a tab that contains a file with modifications in it w/out prompting the user if it’s the case that the same file is displayed in another view.

Which is to say, there is no danger of losing changes because the same file still exists in another tab.

Is that possible?

0 Likes

#2

The view.buffer_id() method will return the same ID value for all clones that are editing the same file, so in theory you could iterate over all views in all windows to see if there’s another view that has the same buffer ID as this one. If you found one, then you could set the scratch parameter on your current view to be able to close it.

So in that sense I think it should be possible; I think the trick would be in detecting that the close is happening and doing this before Sublime asks you to confirm, though.

0 Likes

#3

Thanks for the tip!

0 Likes