Skip to content

Commit d6523c1

Browse files
author
Jonathan Plasse
committed
Fix MaskedInput selection replace with invalid value
1 parent a05cffa commit d6523c1

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
@@ -610,6 +610,18 @@ def insert_text_at_cursor(self, text: str) -> None:
610610
else:
611611
self.restricted()
612612

613+
def replace(self, text: str, start: int, end: int):
614+
"""Replace the text between the start and end locations with the given text.
615+
616+
Args:
617+
text: Text to replace the existing text with.
618+
start: Start index to replace (inclusive).
619+
end: End index to replace (inclusive).
620+
"""
621+
622+
self.cursor_position = start
623+
self.insert_text_at_cursor(text)
624+
613625
def clear(self) -> None:
614626
"""Clear the masked input."""
615627
self.value, self.cursor_position = self._template.insert_separators("", 0)

0 commit comments

Comments
 (0)