Fix inverted char boundary check causing invalid offsets (#47112)

Jordi Villar created

The logic in `anchor_at_offset` and `to_offset` seems inverted when
checking character boundaries. `assert_char_boundary` returns `true`
when the offset IS valid, but the code was adjusting offsets when the
function returned `true` (valid) instead of `false` (invalid).

Release Notes:

- N/A

Change summary

crates/text/src/text.rs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Detailed changes

crates/text/src/text.rs 🔗

@@ -2417,7 +2417,7 @@ impl BufferSnapshot {
         {
             Anchor::max_for_buffer(self.remote_id)
         } else {
-            if self
+            if !self
                 .visible_text
                 .assert_char_boundary::<{ cfg!(debug_assertions) }>(offset)
             {
@@ -3125,7 +3125,7 @@ impl ToOffset for Point {
 impl ToOffset for usize {
     #[track_caller]
     fn to_offset(&self, snapshot: &BufferSnapshot) -> usize {
-        if snapshot
+        if !snapshot
             .as_rope()
             .assert_char_boundary::<{ cfg!(debug_assertions) }>(*self)
         {