Text not displayed in code completion window when AvalonEdit used from c# code

未关闭
#433 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
csharp
领域
desktop

调研方向

使用提供的 C# ICompletionData 和 TextArea completion-window 示例重现该问题,然后跟踪 completion-window 的显示路径。使用包含 Item1 到 Item13 的示例确认该行为,并在每个补全项的文本都能在窗口中显示时将该问题视为完成。

由索引模型根据 Issue 内容生成。

描述

20241102203136

public class VariableCompletionData : ICompletionData
{
  public IImage? Image => null;

  public string Text { get; }

  // Use this property if you want to show a fancy UIElement in the list.
  public object Content => Text;

  public object Description => "Description for " + Text;

  public double Priority { get; } = 0;

  public VariableCompletionData(string text)
  {
    Text = text;
  }

  public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
  {
    textArea.Document.Replace(completionSegment, Text);
  }
}
private void TextArea_TextEntering(object? sender, TextInputEventArgs e)
{
  if (e.Text?.Length > 0 && _completionWindow != null)
  {
    if (!char.IsLetterOrDigit(e.Text[0]))
    {
      // Whenever a non-letter is typed while the completion window is open,
      // insert the currently selected element.
      _completionWindow.CompletionList.RequestInsertion(e);
    }
  }
}

private void TextArea_TextEntered(object? sender, TextInputEventArgs e)
{
  if (e.Text == ".")
  {
    _completionWindow = new CompletionWindow(Editor.TextArea);
    _completionWindow.Closed += (o, args) => _completionWindow = null;

    var data = _completionWindow.CompletionList.CompletionData;

    data.Add(new VariableCompletionData("Item1"));
    data.Add(new VariableCompletionData("Item2"));
    data.Add(new VariableCompletionData("Item3"));
    data.Add(new VariableCompletionData("Item4"));
    data.Add(new VariableCompletionData("Item5"));
    data.Add(new VariableCompletionData("Item6"));
    data.Add(new VariableCompletionData("Item7"));
    data.Add(new VariableCompletionData("Item8"));
    data.Add(new VariableCompletionData("Item9"));
    data.Add(new VariableCompletionData("Item10"));
    data.Add(new VariableCompletionData("Item11"));
    data.Add(new VariableCompletionData("Item12"));
    data.Add(new VariableCompletionData("Item13"));

    _completionWindow.Show();
  }
}
主要语言
C#
星标
2.1k
派生
496
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

icsharpcode/AvalonEdit 的其他 Issue

查看 icsharpcode/AvalonEdit 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。