键入时更新 Roslyn 文档的正确方法是什么? [英] What's the right way to update Roslyn's Document while typing?
问题描述
当用户输入新文本时,更新 Roslyn 的 Document
的正确方法是什么?我应该在每个字符上调用 SourceText.WithChanges
然后 Document.WithText
还是有更有效的方法?
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?
不幸的是,节流不是答案,请参阅我的问题 打字时使用 Roslyn 的 CompletionSevice 的最有效方法是什么? 其中 API 意味着 SourceText
/Document
必须在每个字符上保持最新.
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.
推荐答案
对每个字符执行 SourceText.WithChanges 可能是您最好的选择,假设没有更有效的方法可以创建您自己的 SourceText 派生类型,就像我们在视觉工作室.(请参阅我对您的其他问题的回答.)我们已经做了一些位工作,以确保效率不会太低.
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.
这篇关于键入时更新 Roslyn 文档的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!