Freigeben über


IAsyncCompletionUniversalSource.TryCommit Method

Definition

Allows the implementer of IAsyncCompletionCommitManager to customize how specified CompletionItem is committed. This method is called on UI thread, before the typedChar is inserted into the buffer.

In most cases, implementer does not need to commit the item. Return Unhandled to allow another IAsyncCompletionCommitManager to attempt the commit, or to invoke the default commit behavior.

To perform a custom commit, replace contents of buffer at a location indicated by ApplicableToSpan with text stored in InsertText. To move the caret, use TextView. Finally, return Handled. Use Behavior to influence Editor's behavior after invoking this method.

typedChar may be a non-printable character to denote a commit gesture other than typing. \t denotes pressing Tab key, \n denotes pressing Return key and \0 denotes programmatic commit through API, Ctrl+Space gesture or double clicking an item.

Called on UI thread.

public:
 Microsoft::VisualStudio::Language::Intellisense::AsyncCompletion::Data::CommitResult TryCommit(Microsoft::VisualStudio::Language::Intellisense::AsyncCompletion::IAsyncCompletionSession ^ session, Microsoft::VisualStudio::Text::ITextBuffer ^ buffer, Microsoft::VisualStudio::Language::Intellisense::AsyncCompletion::Data::CompletionItem ^ item, char typedChar, System::Threading::CancellationToken token);
public Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data.CommitResult TryCommit (Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.IAsyncCompletionSession session, Microsoft.VisualStudio.Text.ITextBuffer buffer, Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data.CompletionItem item, char typedChar, System.Threading.CancellationToken token);
abstract member TryCommit : Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.IAsyncCompletionSession * Microsoft.VisualStudio.Text.ITextBuffer * Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data.CompletionItem * char * System.Threading.CancellationToken -> Microsoft.VisualStudio.Language.Intellisense.AsyncCompletion.Data.CommitResult
Public Function TryCommit (session As IAsyncCompletionSession, buffer As ITextBuffer, item As CompletionItem, typedChar As Char, token As CancellationToken) As CommitResult

Parameters

buffer
ITextBuffer

Subject buffer which matches this IAsyncCompletionCommitManager's content type

item
CompletionItem

Which CompletionItem is to be committed

typedChar
Char

Text change associated with this commit. \t denotes Tab key, \n denotes Return key and \0 denotes programmatic commit

token
CancellationToken

Token used to cancel this operation

Returns

Instruction for the editor how to proceed after invoking this method. Default is Unhandled

Applies to