fixup typos

This commit is contained in:
temportalflux
2026-07-11 09:31:07 -04:00
parent 25f922283a
commit 8f99657171
5 changed files with 13 additions and 14 deletions
+1 -1
View File
@@ -108,7 +108,7 @@
//! |_window, _cx| StringStorage::from("this is some default text content"));
//!
//! // Its also plausible to omit the state function call. The element will try to find the state
//! // according to its id (which we are trusting here was garunteed to be at that id above).
//! // according to its id (which we are trusting here was guaranteed to be at that id above).
//! // Despite this functionality, its recommended that callers which construct a state explicitly
//! // provide it to the element, at least for clarity and debugging.
//! text_input(id)
@@ -1,7 +1,6 @@
use std::time::Duration;
use gpui::{Context, Entity, EventEmitter, Subscription, Task};
use gpui::{Context, Entity, EventEmitter, Subscription};
use smallvec::SmallVec;
use std::time::Duration;
/// Default interval for caret blinking (500ms).
pub const DEFAULT_BLINK_INTERVAL: Duration = Duration::from_millis(500);
@@ -437,7 +437,7 @@ impl EditableTextElement {
unimplemented!("all input elements must be assigned an id")
};
let state = EditableTextState::use_keyed(element_id.clone(), window, cx);
let state = EditableTextState::use_keyed(element_id, window, cx);
// store a reference to the entity owned by the element for access in action handlers
*self.state_entity_rc().borrow_mut() = state.downgrade();
state
@@ -151,7 +151,7 @@ impl HistoryEntry {
range: self.range.start..self.range.start + self.old_text.len(),
old_text: prev_text_at_range,
new_text_len: self.old_text.len(),
selected_range: self.selected_range.clone(),
selected_range: self.selected_range,
timestamp: self.timestamp,
}
}
@@ -306,7 +306,7 @@ enum TextSegmentQuery {
// Screen space (text layout engine output) & String space transformers
impl EditableTextState {
/// Attempts to find a text segment based on the provided query parameters.
/// If found, the returned tuple is the segment & the number of preceeding visual rows.
/// If found, the returned tuple is the segment & the number of preceding visual rows.
/// If not found, the resulting "err" is the total number of visual rows of all line segments.
fn find_segment(&self, query: TextSegmentQuery) -> Result<(&TextLineSegment, usize), usize> {
let mut row_count = 0;
@@ -336,7 +336,7 @@ impl EditableTextState {
}
let segment = self.find_segment(TextSegmentQuery::ScreenPosition { point, line_height });
let Ok((segment, _preceeding_row_count)) = segment else {
let Ok((segment, _preceding_row_count)) = segment else {
return storage_len_utf8;
};
@@ -355,13 +355,13 @@ impl EditableTextState {
let target_line_index = caret_line_index.saturating_add_signed(direction as isize);
let segment = self.find_segment(TextSegmentQuery::Row(target_line_index));
let Ok((segment, preceeding_row_count)) = segment else {
let Ok((segment, preceding_row_count)) = segment else {
return (direction > 0).then(|| self.as_str().len());
};
// calculate the screen space position of the row we are navigating to,
// relative to the y-position of the segment.
let row_index = (target_line_index - preceeding_row_count) as f32;
let row_index = (target_line_index - preceding_row_count) as f32;
let relative_point = gpui::point(caret_point.x, row_index * line_height);
Some(segment.character_index_at_point(relative_point, line_height))
@@ -374,7 +374,7 @@ impl EditableTextState {
let caret_pos = self.caret_pos();
let segment = self.find_segment(TextSegmentQuery::CharacterPosition(caret_pos));
let (segment, preceeding_row_count) = match segment {
let (segment, preceding_row_count) = match segment {
Ok(segment) => segment,
Err(total_row_count) => return (total_row_count.saturating_sub(1), Point::default()),
};
@@ -385,12 +385,12 @@ impl EditableTextState {
let point = relative_point.unwrap_or_default();
// the visual row offset from the start of the segment
let row_offset = (point.y / line_height).floor() as usize;
(preceeding_row_count + row_offset, point)
(preceding_row_count + row_offset, point)
}
fn find_point_for_character_position(&self, character_pos: usize) -> Point<Pixels> {
let segment = self.find_segment(TextSegmentQuery::CharacterPosition(character_pos));
let Ok((segment, preceeding_row_count)) = segment else {
let Ok((segment, preceding_row_count)) = segment else {
return Point::default();
};
let line_height = self.layout_data.line_height;
@@ -398,7 +398,7 @@ impl EditableTextState {
// Find the screen position relative to this segment where the caret is at.
let relative_point = segment.position_for_index(character_pos, line_height);
let line_origin = point(Pixels::ZERO, preceeding_row_count as f32 * line_height);
let line_origin = point(Pixels::ZERO, preceding_row_count as f32 * line_height);
return line_origin + relative_point.unwrap_or_default();
}
}