* Replaces a range in the document with the new `text`. * @param {Range | IRange} range A specified Range to replace * @param {String} text The new text to use as a replacement * @returns {Point} Returns an object containing the final row and column, like this: * {row: endRow
(range, text)
| 484 | * |
| 485 | **/ |
| 486 | replace(range, text) { |
| 487 | if (!(range instanceof Range)) |
| 488 | range = Range.fromPoints(range.start, range.end); |
| 489 | // @ts-expect-error |
| 490 | if (text.length === 0 && range.isEmpty()) |
| 491 | return range.start; |
| 492 | |
| 493 | // Shortcut: If the text we want to insert is the same as it is already |
| 494 | // in the document, we don't have to replace anything. |
| 495 | if (text == this.getTextRange(range)) |
| 496 | return range.end; |
| 497 | |
| 498 | this.remove(range); |
| 499 | var end; |
| 500 | if (text) { |
| 501 | end = this.insert(range.start, text); |
| 502 | } |
| 503 | else { |
| 504 | end = range.start; |
| 505 | } |
| 506 | |
| 507 | return end; |
| 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Applies all changes in `deltas` to the document. |
nothing calls this directly
no test coverage detected