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)
| 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. |
no test coverage detected