我必须等待什么事件才能安全访问 IWpfTextView.TextViewLines

发布于 2024-12-27 23:18:11 字数 341 浏览 5 评论 0原文

我开始为 VS 编辑器编写一个装饰器,并且我的数据很大程度上基于行号,因此我需要访问 IWpfTextView 上的 TextViewLines 属性来计算我的装饰器集。

但是,当调用 TextViewCreated 时,该属性仍然为 Null。

我尝试等待第一次调用 OnViewLayoutChanged,实际上该属性当时不为空,但行数为“2”,对于 50 行文件,似乎只是前两行。

我需要什么时间才能获得完全初始化的 TextViewLines,该 TextViewLines 实际上反映了完整的文件内容?或者我误解了我应该得到什么?

这适用于 VS2010 SP1 上的 csharp 内容类型。

I'm starting out writing an adorner for the VS editor and my data is heavily based on line numbers, so I need access to the TextViewLines property on IWpfTextView to calculate my set of adorners.

However, when TextViewCreated is called, the property is still Null.

I tried instead waiting for the first call to OnViewLayoutChanged, and indeed the property wasn't null at that time, but the count of lines was '2', for a 50 line file and appeared to just be the first two lines.

What's the timing I need here to get a fully initialised TextViewLines that actually reflects the full file content? Or am I misunderstanding what I'm supposed to get?

This is for the csharp content type on VS2010 SP1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文