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

Method snap_to_content_pos

src/text_input.rs:1099–1112  ·  view source on GitHub ↗

Snap `cursor_pos` (and `selection_anchor`) so they only land on visible-character boundaries, skipping `}` and empty-content markers. No-op when `no_styles_movement` is false.

(&mut self)

Source from the content-addressed store, hash-verified

1097 /// visible-character boundaries, skipping `}` and empty-content markers.
1098 /// No-op when `no_styles_movement` is false.
1099 fn snap_to_content_pos(&mut self) {
1100 if !self.no_styles_movement { return; }
1101 let cp = styling::cursor_to_content(&self.text, self.cursor_pos);
1102 self.cursor_pos = styling::content_to_cursor(&self.text, cp, true);
1103 if let Some(anchor) = self.selection_anchor {
1104 let ac = styling::cursor_to_content(&self.text, anchor);
1105 self.selection_anchor = Some(
1106 styling::content_to_cursor(&self.text, ac, true),
1107 );
1108 if self.selection_anchor == Some(self.cursor_pos) {
1109 self.selection_anchor = None;
1110 }
1111 }
1112 }
1113
1114 /// Cleanup empty styles after a cursor movement.
1115 /// Called after any movement that doesn't modify text.

Callers 8

backspace_styledMethod · 0.80
delete_forward_styledMethod · 0.80
backspace_word_styledMethod · 0.80
select_all_styledMethod · 0.80
select_word_at_styledMethod · 0.80
cleanup_after_moveMethod · 0.80

Calls 2

cursor_to_contentFunction · 0.85
content_to_cursorFunction · 0.85

Tested by

no test coverage detected