Compartir a través de


CompletionSet.OnCommit Method

Gets the text to be inserted into the source file if the specified character is a commit character.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)

Syntax

'Declaration
Public Overridable Function OnCommit ( _
    textSoFar As String, _
    index As Integer, _
    selected As Integer, _
    commitChar As UShort, _
    <OutAttribute> ByRef completeWord As String _
) As Integer
public virtual int OnCommit(
    string textSoFar,
    int index,
    int selected,
    ushort commitChar,
    out string completeWord
)
public:
virtual int OnCommit(
    String^ textSoFar, 
    int index, 
    int selected, 
    unsigned short commitChar, 
    [OutAttribute] String^% completeWord
)
abstract OnCommit : 
        textSoFar:string * 
        index:int * 
        selected:int * 
        commitChar:uint16 * 
        completeWord:string byref -> int  
override OnCommit : 
        textSoFar:string * 
        index:int * 
        selected:int * 
        commitChar:uint16 * 
        completeWord:string byref -> int
public function OnCommit(
    textSoFar : String, 
    index : int, 
    selected : int, 
    commitChar : ushort, 
    completeWord : String
) : int

Parameters

  • textSoFar
    Type: String

    [in] A string containing the text that has been typed so far by the user.

  • index
    Type: Int32

    [in] The index of the item in the completion list that is currently selected.

  • selected
    Type: Int32

    [in] Nonzero if an item is selected in the completion list (the index of the selected item is in the index parameter). If this parameter is zero, the index parameter is to be ignored.

  • commitChar
    Type: UInt16

    [in] The typed character that triggered the completion list.

  • completeWord
    Type: String%

    [out] Returns the string to insert in the source.

Return Value

Type: Int32
If successful, returns S_OK. If the commitChar parameter is not a commit character, returns S_FALSE (do not commit the text to the source file); otherwise, returns an error code.

Implements

IVsCompletionSet.OnCommit(String, Int32, Int32, UInt16, String%)

Remarks

This method determines if the given character is a commit character and if so, determines the text to be committed based on the item selected in the completion list. If the character is not a commit character, this method returns the text typed so far.

This method is an implementation of the OnCommit method on the IVsCompletionSet interface.

If the commitChar parameter is not 0, then the base method examines the items in the Declarations object to see if the commitChar parameter is contained in any of the possible matches to the text typed so far (if the potential commit character appears after the text typed so far in any declaration, the character cannot be a commit character). If the commitChar parameter could be a real commit character, the base method calls IsCommitChar on the Declarations object to make the final determination.

If the commitChar parameter is 0 or is determined to be an actual commit character, the base method calls the OnCommit method on the Declarations object to obtain the text of the selected item. Finally, the base method returns the text and the success code, S_OK. If the commitChar parameter is not a commit character, the base method returns S_FALSE.

.NET Framework Security

See Also

Reference

CompletionSet Class

Microsoft.VisualStudio.Package Namespace