/// <summary> /// In a perfect world this would replace the contents of the existing ITextView /// with those of the specified file. Unfortunately this causes problems in /// Visual Studio when the file is of a different content type. Instead we /// mimic the behavior by opening the document in a new window and closing the /// existing one /// </summary> public override HostResult LoadFileIntoExistingWindow(string filePath, ITextBuffer textBuffer) { try { // Open the document before closing the other. That way any error which occurs // during an open will cause the method to abandon and produce a user error // message VsShellUtilities.OpenDocument(_adapter.ServiceProvider, filePath); _textManager.Close(textBuffer, false); return(HostResult.Success); } catch (Exception e) { return(HostResult.NewError(e.Message)); } }
public void Close_NoAdapter() { var textBuffer = _factory.Create <ITextBuffer>().Object; Assert.IsFalse(_manager.Close(textBuffer, false)); }