From 30e5d554175672a3067111250670ba0d4d9d1674 Mon Sep 17 00:00:00 2001
From: rustbasic <127506429+rustbasic@users.noreply.github.com>
Date: Tue, 6 Feb 2024 11:50:33 +0900
Subject: [PATCH] Update text_buffer.rs

#3878

panic patch
---
 crates/egui/src/widgets/text_edit/text_buffer.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/crates/egui/src/widgets/text_edit/text_buffer.rs b/crates/egui/src/widgets/text_edit/text_buffer.rs
index f28878a1dd31..e70ce695af9a 100644
--- a/crates/egui/src/widgets/text_edit/text_buffer.rs
+++ b/crates/egui/src/widgets/text_edit/text_buffer.rs
@@ -89,10 +89,12 @@ pub trait TextBuffer {
     fn decrease_indentation(&mut self, ccursor: &mut CCursor) {
         let line_start = find_line_start(self.as_str(), *ccursor);
 
-        let remove_len = if self.as_str()[line_start.index..].starts_with('\t') {
+        let remove_len = if self.as_str().chars().nth(line_start.index) == Some('\t') {
             Some(1)
-        } else if self.as_str()[line_start.index..]
+        } else if self
+            .as_str()
             .chars()
+            .skip(line_start.index)
             .take(TAB_SIZE)
             .all(|c| c == ' ')
         {