---
title: "OffsetMapping"
description: "Provides bidirectional offset mapping between original and transformed text."
type: "interface"
---

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


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

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



```kotlin
interface OffsetMapping
```


Provides bidirectional offset mapping between original and transformed text.


## Functions

```kotlin
fun originalToTransformed(offset: Int): Int
```


Convert offset in original text into the offset in transformed text.

This function must be a monotonically non-decreasing function. In other words, if a cursor
advances in the original text, the cursor in the transformed text must advance or stay there.

#### Parameters

| | |
| --- | --- |
| offset | offset in original text. |


#### Returns

| | |
| --- | --- |
|  | offset in transformed text |



```kotlin
fun transformedToOriginal(offset: Int): Int
```


Convert offset in transformed text into the offset in original text.

This function must be a monotonically non-decreasing function. In other words, if a cursor
advances in the transformed text, the cursor in the original text must advance or stay there.

#### Parameters

| | |
| --- | --- |
| offset | offset in transformed text |


#### Returns

| | |
| --- | --- |
|  | offset in original text |




