What's the right way to update Roslyn's Document while typing?

血红的双手。 提交于 2019-12-10 11:26:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!