Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
debugger: Fix debug console persist to history when reusing a previous item (#34893)
Remco Smits446d333515fc
diff --git a/crates/project/src/search_history.rs b/crates/project/src/search_history.rsindex b84c2e09820..90b169bb0c5 100644--- a/crates/project/src/search_history.rs+++ b/crates/project/src/search_history.rs@@ -45,12 +45,6 @@ impl SearchHistory {}pub fn add(&mut self, cursor: &mut SearchHistoryCursor, search_string: String) {- if let Some(selected_ix) = cursor.selection {- if self.history.get(selected_ix) == Some(&search_string) {- return;- }- }-if self.insertion_behavior == QueryInsertionBehavior::ReplacePreviousIfContains {if let Some(previously_searched) = self.history.back_mut() {if search_string.contains(previously_searched.as_str()) {@@ -144,6 +138,14 @@ mod tests {);assert_eq!(search_history.current(&cursor), Some("rustlang"));+ // add item when it equals to current item if it's not the last one+ search_history.add(&mut cursor, "php".to_string());+ search_history.previous(&mut cursor);+ assert_eq!(search_history.current(&cursor), Some("rustlang"));+ search_history.add(&mut cursor, "rustlang".to_string());+ assert_eq!(search_history.history.len(), 3, "Should add item");+ assert_eq!(search_history.current(&cursor), Some("rustlang"));+// push enough items to test SEARCH_HISTORY_LIMITfor i in 0..MAX_HISTORY_LEN * 2 {search_history.add(&mut cursor, format!("item{i}"));