CompletionContext: dispose() gracefully on buffer change

The buffer can change during dispose(), as explained in the code.
The commit here doesn't fix all the issue, but dispose() should now run
correctly if the buffer changed.