Skip to content

Commit cdd5f1c

Browse files
chore: code review
1 parent 46b864d commit cdd5f1c

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

editor/src/messages/tool/tool_messages/text_tool.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,9 @@ impl Fsm for TextToolFsmState {
846846
}
847847

848848
if let Some(selection_start) = tool_data.selection_start_byte_offset {
849-
let start = selection_start.min(tool_data.cursor_byte_offset);
850-
let end = selection_start.max(tool_data.cursor_byte_offset);
849+
let text_len = tool_data.new_text.len();
850+
let start = selection_start.min(tool_data.cursor_byte_offset).min(text_len);
851+
let end = selection_start.max(tool_data.cursor_byte_offset).min(text_len);
851852
if start != end {
852853
let rects = graphene_std::text::selection_rectangles(&tool_data.new_text, &font_resource, editing_text.typesetting, start, end);
853854
for [top_left, bottom_right] in rects {
@@ -930,10 +931,9 @@ impl Fsm for TextToolFsmState {
930931
&& clicked_text_layer_path == tool_data.layer
931932
{
932933
let click_offset = tool_data.find_closest_byte_offset(document, input.mouse.position, fonts, responses).unwrap_or(tool_data.new_text.len());
933-
if tool_data.selection_type == TextSelectionType::Character {
934-
tool_data.cursor_byte_offset = click_offset;
935-
tool_data.selection_start_byte_offset = Some(click_offset);
936-
}
934+
tool_data.selection_type = TextSelectionType::Character;
935+
tool_data.cursor_byte_offset = click_offset;
936+
tool_data.selection_start_byte_offset = Some(click_offset);
937937
tool_data.dragging_to_select = true;
938938
tool_data.last_edit_type = TextEditType::None;
939939
tool_data.schedule_cursor_draw(responses);

0 commit comments

Comments
 (0)