CompletionSet.OnCommit(String, Int32, Int32, UInt16, String) Method

Definition

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

public:
 virtual int OnCommit(System::String ^ textSoFar, int index, int selected, System::UInt16 commitChar, [Runtime::InteropServices::Out] System::String ^ % completeWord);
 virtual int OnCommit(std::wstring const & textSoFar, int index, int selected, unsigned short commitChar, [Runtime::InteropServices::Out] std::wstring const & & completeWord);
public virtual int OnCommit (string textSoFar, int index, int selected, ushort commitChar, out string completeWord);
abstract member OnCommit : string * int * int * uint16 * string -> int
override this.OnCommit : string * int * int * uint16 * string -> int
Public Overridable Function OnCommit (textSoFar As String, index As Integer, selected As Integer, commitChar As UShort, ByRef completeWord As String) As Integer

Parameters

textSoFar
String

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

index
Int32

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

selected
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
UInt16

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

completeWord
String

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

Returns

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

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.

Applies to