Commit 716e732469

716e732469ab66ca2e4c615d021cb3a83cc37a5b

parent: c347aad699

Unsigned

Vaibhav Mattoo <vaibhavmattoo1@gmail.com> · 2025-08-16 07:30 UTC

fix: solved thread 'main' panic due to incorrect cursor position after scrolling up and down through command history

Layout: unified · split

src/global/functions/command_capture.rs +4
@@ -137,6 +137,10 @@ pub fn command_capture(framework: &mut FrameworkClean, key: KeyEvent) -> bool {
137 let text_field = status.command_capture.as_mut().unwrap(); 137 let text_field = status.command_capture.as_mut().unwrap();
138 status.command_history_index = None; 138 status.command_history_index = None;
139 text_field.content = status.command_editing_cache.clone(); 139 text_field.content = status.command_editing_cache.clone();
140 text_field.cursor = text_field.cursor.min(text_field.content.len());
141 if !text_field.content.is_empty() {
142 let _ = text_field.last();
143 }
140 } else { 144 } else {
141 let new_index = status.command_history_index.unwrap_or(history.0.len()) + 1; 145 let new_index = status.command_history_index.unwrap_or(history.0.len()) + 1;
142 let new_content = history.0[new_index].clone(); 146 let new_content = history.0[new_index].clone();
src/run.rs +5
@@ -174,6 +174,11 @@ pub fn run(
174 status.command_history_index = None; 174 status.command_history_index = None;
175 text_field.content = 175 text_field.content =
176 status.command_editing_cache.clone(); 176 status.command_editing_cache.clone();
177 text_field.cursor =
178 text_field.cursor.min(text_field.content.len());
179 if !text_field.content.is_empty() {
180 let _ = text_field.last();
181 }
177 } else { 182 } else {
178 let new_index = status 183 let new_index = status
179 .command_history_index 184 .command_history_index