---
title: "EditProcessor"
description: "Helper class to apply [EditCommand]s on an internal buffer. Used by TextField Composable to
combine TextFieldValue lifecycle with the editing operations.
* When a [TextFieldValue] is suggested by the developer, [reset] should be called.
* When [TextInputService] provides [EditCommand]s, they should be applied to the internal buffer using [apply]."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>


```kotlin
class EditProcessor
```


Helper class to apply `EditCommand`s on an internal buffer. Used by TextField Composable to
combine TextFieldValue lifecycle with the editing operations.
* When a `TextFieldValue` is suggested by the developer, `reset` should be called.
* When `TextInputService` provides `EditCommand`s, they should be applied to the internal buffer using `apply`.


## Functions

```kotlin
fun reset(value: TextFieldValue, textInputSession: TextInputSession?)
```


Must be called whenever new editor model arrives.

This method updates the internal editing buffer with the given editor model. This method may
tell the IME about the selection offset changes or extracted text changes.


```kotlin
fun apply(editCommands: List<EditCommand>): TextFieldValue
```


Applies a set of `editCommands` to the internal text editing buffer.

After applying the changes, returns the final state of the editing buffer as a
`TextFieldValue`

#### Parameters

| | |
| --- | --- |
| editCommands | `EditCommand`s to be applied to the editing buffer. |


#### Returns

| | |
| --- | --- |
|  | the `TextFieldValue` representation of the final buffer state. |



```kotlin
fun toTextFieldValue(): TextFieldValue
```


Returns the current state of the internal editing buffer as a `TextFieldValue`.



