---
title: "requestTextContextForAutocorrection(completionHandler:)"
framework: browserenginekit
role: symbol
role_heading: Instance Method
path: "browserenginekit/betextinput/requesttextcontextforautocorrection(completionhandler:)"
---

# requestTextContextForAutocorrection(completionHandler:)

A method the text system calls to get extra information for autocorrection suggestions.

## Declaration

```swift
func requestTextContextForAutocorrection(completionHandler: @escaping @Sendable (BETextDocumentContext) -> Void)
```

```swift
func requestTextContextForAutocorrection() async -> BETextDocumentContext
```

## Parameters

- `completionHandler`: A closure that you call to supply the context as a doc://com.apple.BrowserEngineKit/documentation/BrowserEngineKit/BETextDocumentContext.

## Mentioned in

Integrating custom browser text views with UIKit

## Discussion

Discussion The system calls this method to retrieve extra context for the currently selected text. Construct a BETextDocumentContext that contains complete sentences that also include the current selection. If the selection is at a sentence boundary, also include the preceding sentence.

## See Also

### Requesting context

- [requestDocumentContext(_:completionHandler:)](browserenginekit/betextinput/requestdocumentcontext(_:completionhandler:).md)
- [requestTextRects(for:withCompletionHandler:)](browserenginekit/betextinput/requesttextrects(for:withcompletionhandler:).md)
