Declarations.OnCommit Method

Called to commit the specified item to the source file.

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


Public Overridable Function OnCommit ( _
    textView As IVsTextView, _
    textSoFar As String, _
    commitCharacter As Char, _
    index As Integer, _
    ByRef initialExtent As TextSpan _
) As String
public virtual string OnCommit(
    IVsTextView textView,
    string textSoFar,
    char commitCharacter,
    int index,
    ref TextSpan initialExtent
virtual String^ OnCommit(
    IVsTextView^ textView, 
    String^ textSoFar, 
    wchar_t commitCharacter, 
    int index, 
    TextSpan% initialExtent
abstract OnCommit : 
        textView:IVsTextView * 
        textSoFar:string * 
        commitCharacter:char * 
        index:int * 
        initialExtent:TextSpan byref -> string  
override OnCommit : 
        textView:IVsTextView * 
        textSoFar:string * 
        commitCharacter:char * 
        index:int * 
        initialExtent:TextSpan byref -> string
public function OnCommit(
    textView : IVsTextView, 
    textSoFar : String, 
    commitCharacter : char, 
    index : int, 
    initialExtent : TextSpan
) : String


  • textSoFar
    Type: System.String

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

  • commitCharacter
    Type: System.Char

    [in] The character used to commit the text.

  • index
    Type: System.Int32

    [in] The index of the item to commit to the source file.

Return Value

Type: System.String
If successful, returns a string containing the text to commit to the source file; otherwise, returns nulla null reference (Nothing in Visual Basic).


What is actually committed is dependent on how you implement the Declarations class. Typically, what is shown in the completion list is also what is returned from this method so there is a one-to-one correspondence to what the user sees in the list and what is inserted into the source file. Sometimes, however, what is shown in the list is not what should be inserted into the source file. For example, in C++, the completion list might show a complete method signature but what is actually inserted is only the name of the method.

The base method returns the string returned from a call to the GetName method.

.NET Framework Security

See Also


Declarations Class

Microsoft.VisualStudio.Package Namespace