0

나는 Walkthrough: Displaying Statement Completion을 다시 만들고 관리 할 수있었습니다. 그러나 사용자 지정 텍스트를 추가 할 수 있는지 궁금합니다.자동 완성 Visual Studio

Highlighted

나는 그것이 /를 도시 장소를 찾을 수 없습니다 강조 표시된 "# 적응-samelevel 팝업을 호출합니다. 내가 대신 작은 설명을 말할 수 있도록 할 것입니다. 그냥

답변

1

추가하십시오 사용자 정의 테스트 :.

void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) 
    { 
     List<string> strList = new List<string>(); 
     strList.Add("addition"); 
     strList.Add("adaptation"); 
     strList.Add("subtraction"); 
     strList.Add("test"); 
     strList.Add("text"); 
     strList.Add("t~e#@xt"); 
     strList.Add("@text"); 
     strList.Add("@aaaaaa"); 
     strList.Add("~text"); 
     strList.Add("#adapt-samelevel"); 
     strList.Add("#abort"); 
     strList.Add("#adapt"); 
     strList.Add("#adapt-modified"); 
     m_compList = new List<Completion>(); 
     foreach (string str in strList) 
      //please add custom texts as you want 
      m_compList.Add(new Completion(str, str, "Test", null, null)); 

     completionSets.Add(new CompletionSet(
      "Tokens", //the non-localized title of the tab 
      "Tokens", //the display title of the tab 
      FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), 
       session), 
      m_compList, 
      null)); 
    } 
,

문자와 숫자로 Exec 메서드 (클래스 이름 TestCompletionCommandHandler)에 제약 조건을 만들었습니다. 제약 조건을 수정할 수 있습니다.

if (!typedChar.Equals(char.MinValue)) //remove the constraint 
      { 
       if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion 
       { 
        this.TriggerCompletion(); 
        m_session.Filter(); 
       } 
       else //the completion session is already active, so just filter 
       { 
        m_session.Filter(); 
       } 
       handled = true; 
      } 
으로 다음 코드

if (!typedChar.Equals(char.MinValue) && char.IsLetterOrDigit(typedChar)) 
      { 
       if (m_session == null || m_session.IsDismissed) // If there is no active session, bring up completion 
       { 
        this.TriggerCompletion(); 
        m_session.Filter(); 
       } 
       else //the completion session is already active, so just filter 
       { 
        m_session.Filter(); 
       } 
       handled = true; 
      } 

변경

enter image description here

enter image description here

편집 :

이 같은 어법을 대신 문자열을 사용할 수 있습니다

void ICompletionSource.AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets) 
     { 
      Dictionary<string, string> strList = new Dictionary<string, string>(); 
      strList.Add("#adapt-samelevel", "Test1"); 
      strList.Add("abort", "Test2"); 
      strList.Add("#adapt-modified", "Test3"); 
      m_compList = new List<Completion>(); 
      foreach (KeyValuePair<string, string> kvp in strList) 
       m_compList.Add(new Completion(kvp.Key, kvp.Key, kvp.Value, null, null)); 

      completionSets.Add(new CompletionSet(
       "Tokens", //the non-localized title of the tab 
       "Tokens", //the display title of the tab 
       FindTokenSpanAtPosition(session.GetTriggerPoint(m_textBuffer), 
        session), 
       m_compList, 
       null)); 
     } 
+0

안녕하세요, 지금 제가 가지고있는 것입니다. 그러나 나는 hover/scrolled 할 때 튀어 나오는 텍스트를 바꾸려고합니다. 귀하의 예에 따르면, # adapt-samelevel이 강조 표시되어 있고 오른쪽에는 # adapt-samelevel이 다시 표시됩니다. 그 텍스트를 더 유용한 것으로 편집하고 싶습니다. 어떻게해야합니까? –

+1

Jason Malinowski가 말했듯이 설명 속성을 사용하십시오 –

+0

strList 값을 설명과 일치시키는 방법을 모르겠습니다. 예를 들어 주시겠습니까? 감사! –

0

을 당신이 작성하고 추가하려는 완료에 대한 Description property이 같은 ICompletionSource.AugmentCompletionSession 방법에

+0

어디에도 '# adapt-samelevel'설명을 추가하지 않았습니다. 나는 가이드를 따라 갔고, 필자 자신의 완성 변수를 추가했다. 강조 표시된 부분. 저는 힌트를주기 위해 그 부분을 편집하고 싶습니다. –

+0

"# adapt-samelevel"을 사용자 정의 설명과 함께 사용하는 방법에 대한 예를 들어 주시겠습니까? –

관련 문제