Rename clamped -> clipped

Julia created

Change summary

crates/editor/src/editor.rs                   |  2 
crates/editor/src/multi_buffer.rs             | 16 ++++++------
crates/editor/src/selections_collection.rs    |  8 +++---
crates/project/src/project.rs                 |  6 ++--
crates/project_symbols/src/project_symbols.rs |  2 
crates/rope/src/rope.rs                       | 12 ++++----
crates/text/src/text.rs                       | 28 ++++++++++----------
7 files changed, 37 insertions(+), 37 deletions(-)

Detailed changes

crates/editor/src/editor.rs 🔗

@@ -55,7 +55,7 @@ use link_go_to_definition::{
 };
 pub use multi_buffer::{
     Anchor, AnchorRangeExt, ExcerptId, ExcerptRange, MultiBuffer, MultiBufferSnapshot, ToOffset,
-    ToOffsetClamped, ToPoint,
+    ToOffsetClipped, ToPoint,
 };
 use multi_buffer::{MultiBufferChunks, ToOffsetUtf16};
 use ordered_float::OrderedFloat;

crates/editor/src/multi_buffer.rs 🔗

@@ -72,8 +72,8 @@ pub trait ToOffset: 'static + fmt::Debug {
     fn to_offset(&self, snapshot: &MultiBufferSnapshot) -> usize;
 }
 
-pub trait ToOffsetClamped: 'static + fmt::Debug {
-    fn to_offset_clamped(&self, snapshot: &MultiBufferSnapshot) -> usize;
+pub trait ToOffsetClipped: 'static + fmt::Debug {
+    fn to_offset_clipped(&self, snapshot: &MultiBufferSnapshot) -> usize;
 }
 
 pub trait ToOffsetUtf16: 'static + fmt::Debug {
@@ -1949,9 +1949,9 @@ impl MultiBufferSnapshot {
         }
     }
 
-    pub fn point_utf16_to_offset_clamped(&self, point: PointUtf16) -> usize {
+    pub fn point_utf16_to_offset_clipped(&self, point: PointUtf16) -> usize {
         if let Some((_, _, buffer)) = self.as_singleton() {
-            return buffer.point_utf16_to_offset_clamped(point);
+            return buffer.point_utf16_to_offset_clipped(point);
         }
 
         let mut cursor = self.excerpts.cursor::<(PointUtf16, usize)>();
@@ -1965,7 +1965,7 @@ impl MultiBufferSnapshot {
                 .offset_to_point_utf16(excerpt.range.context.start.to_offset(&excerpt.buffer));
             let buffer_offset = excerpt
                 .buffer
-                .point_utf16_to_offset_clamped(excerpt_start_point + overshoot);
+                .point_utf16_to_offset_clipped(excerpt_start_point + overshoot);
             *start_offset + (buffer_offset - excerpt_start_offset)
         } else {
             self.excerpts.summary().text.len
@@ -3291,9 +3291,9 @@ impl ToOffset for OffsetUtf16 {
     }
 }
 
-impl ToOffsetClamped for PointUtf16 {
-    fn to_offset_clamped<'a>(&self, snapshot: &MultiBufferSnapshot) -> usize {
-        snapshot.point_utf16_to_offset_clamped(*self)
+impl ToOffsetClipped for PointUtf16 {
+    fn to_offset_clipped<'a>(&self, snapshot: &MultiBufferSnapshot) -> usize {
+        snapshot.point_utf16_to_offset_clipped(*self)
     }
 }
 

crates/editor/src/selections_collection.rs 🔗

@@ -14,7 +14,7 @@ use util::post_inc;
 use crate::{
     display_map::{DisplayMap, DisplaySnapshot, ToDisplayPoint},
     Anchor, DisplayPoint, ExcerptId, MultiBuffer, MultiBufferSnapshot, SelectMode, ToOffset,
-    ToOffsetClamped,
+    ToOffsetClipped,
 };
 
 #[derive(Clone)]
@@ -551,14 +551,14 @@ impl<'a> MutableSelectionsCollection<'a> {
         self.select_offset_ranges(ranges);
     }
 
-    pub fn select_clamped_ranges<I, T>(&mut self, ranges: I)
+    pub fn select_clipped_ranges<I, T>(&mut self, ranges: I)
     where
         I: IntoIterator<Item = Range<T>>,
-        T: ToOffsetClamped,
+        T: ToOffsetClipped,
     {
         let buffer = self.buffer.read(self.cx).snapshot(self.cx);
         let ranges = ranges.into_iter().map(|range| {
-            range.start.to_offset_clamped(&buffer)..range.end.to_offset_clamped(&buffer)
+            range.start.to_offset_clipped(&buffer)..range.end.to_offset_clipped(&buffer)
         });
         self.select_offset_ranges(ranges);
     }

crates/project/src/project.rs 🔗

@@ -25,7 +25,7 @@ use language::{
     range_from_lsp, range_to_lsp, Anchor, Bias, Buffer, CachedLspAdapter, CharKind, CodeAction,
     CodeLabel, Completion, Diagnostic, DiagnosticEntry, DiagnosticSet, Event as BufferEvent,
     File as _, Language, LanguageRegistry, LanguageServerName, LocalFile, OffsetRangeExt,
-    Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToOffsetClamped, ToPointUtf16,
+    Operation, Patch, PointUtf16, TextBufferSnapshot, ToOffset, ToOffsetClipped, ToPointUtf16,
     Transaction,
 };
 use lsp::{
@@ -3369,7 +3369,7 @@ impl Project {
                                     }
                                     let Range { start, end } = range_for_token
                                         .get_or_insert_with(|| {
-                                            let offset = position.to_offset_clamped(&snapshot);
+                                            let offset = position.to_offset_clipped(&snapshot);
                                             let (range, kind) = snapshot.surrounding_word(offset);
                                             if kind == Some(CharKind::Word) {
                                                 range
@@ -5743,7 +5743,7 @@ impl Project {
                 // we can identify the changes more precisely, preserving the locations
                 // of any anchors positioned in the unchanged regions.
                 if range.end.row > range.start.row {
-                    let mut offset = range.start.to_offset_clamped(&snapshot);
+                    let mut offset = range.start.to_offset_clipped(&snapshot);
                     let old_text = snapshot.text_for_clamped_range(range).collect::<String>();
 
                     let diff = TextDiff::from_lines(old_text.as_str(), &new_text);

crates/project_symbols/src/project_symbols.rs 🔗

@@ -151,7 +151,7 @@ impl ProjectSymbolsView {
                         let editor = workspace.open_project_item::<Editor>(buffer, cx);
                         editor.update(cx, |editor, cx| {
                             editor.change_selections(Some(Autoscroll::center()), cx, |s| {
-                                s.select_clamped_ranges([position..position])
+                                s.select_clipped_ranges([position..position])
                             });
                         });
                     });

crates/rope/src/rope.rs 🔗

@@ -259,7 +259,7 @@ impl Rope {
                 .map_or(0, |chunk| chunk.point_to_offset(overshoot))
     }
 
-    pub fn point_utf16_to_offset_clamped(&self, point: PointUtf16) -> usize {
+    pub fn point_utf16_to_offset_clipped(&self, point: PointUtf16) -> usize {
         if point >= self.summary().lines_utf16() {
             return self.summary().len;
         }
@@ -269,7 +269,7 @@ impl Rope {
         cursor.start().1
             + cursor
                 .item()
-                .map_or(0, |chunk| chunk.point_utf16_to_offset_clamped(overshoot))
+                .map_or(0, |chunk| chunk.point_utf16_to_offset_clipped(overshoot))
     }
 
     pub fn point_utf16_to_point(&self, point: PointUtf16) -> Point {
@@ -711,7 +711,7 @@ impl Chunk {
         point_utf16
     }
 
-    fn point_utf16_to_offset_clamped(&self, target: PointUtf16) -> usize {
+    fn point_utf16_to_offset_clipped(&self, target: PointUtf16) -> usize {
         let mut offset = 0;
         let mut point = PointUtf16::new(0, 0);
 
@@ -1210,7 +1210,7 @@ mod tests {
                     point
                 );
                 assert_eq!(
-                    actual.point_utf16_to_offset_clamped(point_utf16),
+                    actual.point_utf16_to_offset_clipped(point_utf16),
                     ix,
                     "point_utf16_to_offset({:?})",
                     point_utf16
@@ -1251,8 +1251,8 @@ mod tests {
                 let right_point = actual.clip_point_utf16(point_utf16, Bias::Right);
                 assert!(right_point >= left_point);
                 // Ensure translating UTF-16 points to offsets doesn't panic.
-                actual.point_utf16_to_offset_clamped(left_point);
-                actual.point_utf16_to_offset_clamped(right_point);
+                actual.point_utf16_to_offset_clipped(left_point);
+                actual.point_utf16_to_offset_clipped(right_point);
 
                 offset_utf16.0 += 1;
                 if unit == b'\n' as u16 {

crates/text/src/text.rs 🔗

@@ -1590,8 +1590,8 @@ impl BufferSnapshot {
         self.visible_text.point_to_offset(point)
     }
 
-    pub fn point_utf16_to_offset_clamped(&self, point: PointUtf16) -> usize {
-        self.visible_text.point_utf16_to_offset_clamped(point)
+    pub fn point_utf16_to_offset_clipped(&self, point: PointUtf16) -> usize {
+        self.visible_text.point_utf16_to_offset_clipped(point)
     }
 
     pub fn point_utf16_to_point(&self, point: PointUtf16) -> Point {
@@ -1649,9 +1649,9 @@ impl BufferSnapshot {
         self.visible_text.chunks_in_range(start..end)
     }
 
-    pub fn text_for_clamped_range<T: ToOffsetClamped>(&self, range: Range<T>) -> Chunks<'_> {
-        let start = range.start.to_offset_clamped(self);
-        let end = range.end.to_offset_clamped(self);
+    pub fn text_for_clamped_range<T: ToOffsetClipped>(&self, range: Range<T>) -> Chunks<'_> {
+        let start = range.start.to_offset_clipped(self);
+        let end = range.end.to_offset_clipped(self);
         self.visible_text.chunks_in_range(start..end)
     }
 
@@ -1804,16 +1804,16 @@ impl BufferSnapshot {
         self.anchor_at(position, Bias::Left)
     }
 
-    pub fn clamped_anchor_before<T: ToOffsetClamped>(&self, position: T) -> Anchor {
-        self.anchor_at_offset(position.to_offset_clamped(self), Bias::Left)
+    pub fn clamped_anchor_before<T: ToOffsetClipped>(&self, position: T) -> Anchor {
+        self.anchor_at_offset(position.to_offset_clipped(self), Bias::Left)
     }
 
     pub fn anchor_after<T: ToOffset>(&self, position: T) -> Anchor {
         self.anchor_at(position, Bias::Right)
     }
 
-    pub fn clamped_anchor_after<T: ToOffsetClamped>(&self, position: T) -> Anchor {
-        self.anchor_at_offset(position.to_offset_clamped(self), Bias::Right)
+    pub fn clamped_anchor_after<T: ToOffsetClipped>(&self, position: T) -> Anchor {
+        self.anchor_at_offset(position.to_offset_clipped(self), Bias::Right)
     }
 
     pub fn anchor_at<T: ToOffset>(&self, position: T, bias: Bias) -> Anchor {
@@ -2395,13 +2395,13 @@ impl<'a, T: ToOffset> ToOffset for &'a T {
     }
 }
 
-pub trait ToOffsetClamped {
-    fn to_offset_clamped(&self, snapshot: &BufferSnapshot) -> usize;
+pub trait ToOffsetClipped {
+    fn to_offset_clipped(&self, snapshot: &BufferSnapshot) -> usize;
 }
 
-impl ToOffsetClamped for PointUtf16 {
-    fn to_offset_clamped<'a>(&self, snapshot: &BufferSnapshot) -> usize {
-        snapshot.point_utf16_to_offset_clamped(*self)
+impl ToOffsetClipped for PointUtf16 {
+    fn to_offset_clipped<'a>(&self, snapshot: &BufferSnapshot) -> usize {
+        snapshot.point_utf16_to_offset_clipped(*self)
     }
 }