【问题标题】:MSDN Statement Completion Special CharactersMSDN 语句完成特殊字符
【发布时间】:2016-09-22 01:24:30
【问题描述】:

我最近关注了https://msdn.microsoft.com/en-us/library/ee372314.aspx 上的演练,并成功地将其与包含的列表一起使用,由此我可以添加简单的字符串值以使其完成我在字符串中键入的任何内容。

 void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
    {
        List<string> strList = new List<string>();

                    strList.Add("addition_test");
                    strList.Add("adaptation");
                    strList.Add("subtraction");
        m_compList = new List<Completion>();
        foreach (string str in strList)
            m_compList.Add(new Completion(str, str, str, null, null));

如图所示,我显示了标准字符串,“addition_test”,“adaptation” 和“减法”。它们都有效。

但是我想知道我是否可以在它前面放置特殊字符。比如

  • strList.Add("#adapt");

  • strList.Add("?adapt_nation");

  • strList.Add("/#@adapt_entity");

我无法让它在前面显示带有特殊字符的语句,我想知道是否有办法做到这一点以及如何做到这一点?

干杯

【问题讨论】:

  • 尝试在字符串前面加上@ 符号,例如strList.Add(@"#adapt"); 等。该符号强制字符串逐字显示,默认情况下不转义。 2.4.4.5 String literals
  • @keyurPatel 你好!我试过这样做,是的,它通过并将“@”符号添加到列表中,但它没有显示在完成中。例如当我输入“ad”时,会显示“addition”,我可以使用空格/输入/选择它来选择它。使用字符串前面的@,我无法完成例如“@ad”没有让我选择完成“@addition”
  • 这似乎更多地与您如何编写“自动更正”功能有关,而不是 c# 如何存储字符串。
  • 你知道怎么做吗,看着msdn.microsoft.com/en-us/library/ee372314.aspx,因为我不知道从哪里开始修改代码。谢谢。
  • 我从来没有遇到过这个,所以我只能推测,但尝试在public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)函数中将&amp;&amp; char.IsLetterOrDigit(typedChar)更改为&amp;&amp; (char.IsLetterOrDigit(typedChar) || char.IsPunctuation(typedChar))

标签: c# autocomplete special-characters intellisense msdn


【解决方案1】:

@Keyur PATEL 的回答

这个我没遇到过,只能推测,但尝试改变

&& char.IsLetterOrDigit(typedChar) 

&& (char.IsLetterOrDigit(typedChar) || char.IsPunctuation(typedChar)) 

public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut) function.

【讨论】:

    猜你喜欢
    • 2017-02-08
    • 1970-01-01
    • 1970-01-01
    • 2020-06-27
    • 2011-09-23
    • 2018-12-21
    • 1970-01-01
    • 2011-09-22
    相关资源
    最近更新 更多