Skip to content

Commit e1f568a

Browse files
author
Jonathan Plasse
committed
Fix MaskedInput selection replace with invalid value
1 parent 2a4fcb7 commit e1f568a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/textual/widgets/_masked_input.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,18 @@ def insert_text_at_cursor(self, text: str) -> None:
618618
else:
619619
self.restricted()
620620

621+
def replace(self, text: str, start: int, end: int):
622+
"""Replace the text between the start and end locations with the given text.
623+
624+
Args:
625+
text: Text to replace the existing text with.
626+
start: Start index to replace (inclusive).
627+
end: End index to replace (inclusive).
628+
"""
629+
630+
self.cursor_position = start
631+
self.insert_text_at_cursor(text)
632+
621633
def clear(self) -> None:
622634
"""Clear the masked input."""
623635
self.value, self.cursor_position = self._template.insert_separators("", 0)

0 commit comments

Comments
 (0)