public void SearchCacheDoesntHoldTheBuffer()
{
var vimBuffer = CreateVimBuffer();
vimBuffer.TextBuffer.SetText("hello world");
vimBuffer.Process("/world", enter: true);
// This will kick off five search items on the thread pool, each of which
// has a strong reference. Need to wait until they have all completed.
var count = 0;
while (count < 5)
{
while (_synchronizationContext.PostedCallbackCount > 0)
{
_synchronizationContext.RunOne();
count++;
}
Thread.Yield();
}
var weakTextBuffer = new WeakReference(vimBuffer.TextBuffer);
// Clean up
vimBuffer.TextView.Close();
vimBuffer = null;
RunGarbageCollector();
Assert.Null(weakTextBuffer.Target);
}