MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / delete_selection_styled

Method delete_selection_styled

src/text_input.rs:584–612  ·  view source on GitHub ↗

Delete selection in styled mode. Returns true if a selection was deleted.

(&mut self)

Source from the content-addressed store, hash-verified

582
583 /// Delete selection in styled mode. Returns true if a selection was deleted.
584 pub fn delete_selection_styled(&mut self) -> bool {
585 if let Some((start, end)) = self.selection_range() {
586 if self.no_styles_movement {
587 let start_cp = styling::cursor_to_content(&self.text, start);
588 let end_cp = styling::cursor_to_content(&self.text, end);
589 if start_cp < end_cp {
590 self.text = styling::delete_content_range(&self.text, start_cp, end_cp);
591 }
592 self.cursor_pos = styling::content_to_cursor(&self.text, start_cp, true);
593 } else {
594 self.text = styling::delete_visual_range(&self.text, start, end);
595 self.cursor_pos = start;
596 }
597 self.selection_anchor = None;
598 // Cleanup empty styles (cursor is at start)
599 let (cleaned, new_pos) = styling::cleanup_empty_styles(&self.text, self.cursor_pos);
600 self.text = cleaned;
601 self.cursor_pos = new_pos;
602 self.snap_to_content_pos();
603 // If no visible content remains after deletion, clear entirely
604 if styling::strip_styling(&self.text).is_empty() {
605 self.text = String::new();
606 self.cursor_pos = 0;
607 }
608 true
609 } else {
610 false
611 }
612 }
613
614 /// Insert text at visual cursor position in styled mode, with escaping.
615 /// The input `s` should already be escaped if needed.

Callers 7

insert_text_styledMethod · 0.80
backspace_styledMethod · 0.80
delete_forward_styledMethod · 0.80
backspace_word_styledMethod · 0.80

Calls 9

cursor_to_contentFunction · 0.85
delete_content_rangeFunction · 0.85
content_to_cursorFunction · 0.85
delete_visual_rangeFunction · 0.85
cleanup_empty_stylesFunction · 0.85
strip_stylingFunction · 0.85
selection_rangeMethod · 0.80
snap_to_content_posMethod · 0.80
is_emptyMethod · 0.80

Tested by 1