This project is read-only.
1
Vote

solution.AddDocument not undoable

description

Hi, I don't know, If I am doing it well, but when I add new Document to Solution in CodeRefactoringProvider and changing syntaxtree, VS will change editing document and creates new one.
But when user presses CTRL+Z (Undo), only changed made to document are revereted, but document is still in project.
        var documentId = DocumentId.CreateNewId(project.Id);
        solution = solution.AddDocument(DocumentInfo.Create(documentId, GetDocumentName(...), document.Folders, SourceCodeKind.Regular));
        ...
        compilationUnit = compilationUnit.AddMembers(root);
        return solution.WithDocumentSyntaxRoot(documentId, compilationUnit);

comments

Pilchie wrote Nov 25, 2014 at 6:30 PM

You're doing it right. Unfortunately, supporting this in VS's undo system is somewhat difficult. This is something we would like to address eventually, but it will probably be a while before we get to it. :-(

Note that this is the same behavior as VS fixes like Generate Type.