VSIX - Event when textview is closing

Viewed 108

The ITextView interface contains a Closed event that is raised after a text view has been closed. But, is it also possible somehow to subscribe to a Closing event, that tells us that a text view is about to close? Just after the user has pressed the close button. It should also be possible to cancel the close operation.

I would like to show a similar pop-up window like the save popup that is shown when the document still has unsaved changes, but with a different purpose.

1 Answers

Normally this behavior would be handled in the container. To answer your question: Have a look at SubjectBuffersDisconnected. By monitoring the underlying link between the text buffer and the view, you have access to the view before it is closed. This will not be able to cancel the Close, but it contains enough information to recreate it as if it had never been closed.

Related