问题
What's the right way to update Roslyn's Document
when user is typing new text? Should I call SourceText.WithChanges
and then Document.WithText
on each char, or is there a more efficient way?
Unfortunately throttling is not an answer, see my question What's the most efficient way to use Roslyn's CompletionSevice when typing? where an API implies that SourceText
/Document
must be up to date on each char.
回答1:
Doing SourceText.WithChanges on each character is probably your best bet, assuming there's not a more efficient way you can create your own derived type of SourceText like we do in Visual Studio. (See my answer to your other question for that.) We have done a bit of work to make that not be too inefficient.
来源:https://stackoverflow.com/questions/39422126/whats-the-right-way-to-update-roslyns-document-while-typing