From 9073818d4e94b01bbb57c02e9d68d4ea5f1aea0c Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Mon, 26 May 2025 22:46:26 +0800 Subject: [PATCH] input: Fix outdent when selection first line is no indent. (#903) ## Before https://github.com/user-attachments/assets/67f94a09-b01b-43e4-9809-2e876f53a7b7 ## After https://github.com/user-attachments/assets/0ff7fee8-cbbc-4f55-8877-96c7ad07d662 --- crates/ui/src/input/state.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/ui/src/input/state.rs b/crates/ui/src/input/state.rs index a661fdbe..85d86f88 100644 --- a/crates/ui/src/input/state.rs +++ b/crates/ui/src/input/state.rs @@ -1304,10 +1304,12 @@ impl InputState { cx, ); removed_len += tab_indent.len(); - } - // +1 for "\n" - offset += line.len().saturating_sub(tab_indent.len()) + 1; + // +1 for "\n" + offset += line.len().saturating_sub(tab_indent.len()) + 1; + } else { + offset += line.len() + 1; + } } self.selected_range = start_offset..selected_range.end.saturating_sub(removed_len);