From c53615ff6104de4da8b90426489b380078a5f705 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 7 Jan 2025 14:42:38 -0500 Subject: [PATCH] assistant2: Add intermediate bindings to improve conditional readability (#22790) This PR adds some intermediate bindings to the checks for if a file/directory is already included to make the conditional a bit clearer. It wasn't immediately obvious what the boolean values corresponded to when looking at it. Release Notes: - N/A --- .../src/context_picker/directory_context_picker.rs | 6 +++--- crates/assistant2/src/context_picker/file_context_picker.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/assistant2/src/context_picker/directory_context_picker.rs b/crates/assistant2/src/context_picker/directory_context_picker.rs index 29d07c2e6941893917a71472257827287dce2f54..11fc9bee0b82c8cb5787acbde5d1fed1f752e28c 100644 --- a/crates/assistant2/src/context_picker/directory_context_picker.rs +++ b/crates/assistant2/src/context_picker/directory_context_picker.rs @@ -188,7 +188,7 @@ impl PickerDelegate for DirectoryContextPickerDelegate { }; let path = mat.path.clone(); - if self + let already_included = self .context_store .update(cx, |context_store, _cx| { if let Some(context_id) = context_store.included_directory(&path) { @@ -198,8 +198,8 @@ impl PickerDelegate for DirectoryContextPickerDelegate { false } }) - .unwrap_or(true) - { + .unwrap_or(true); + if already_included { return; } diff --git a/crates/assistant2/src/context_picker/file_context_picker.rs b/crates/assistant2/src/context_picker/file_context_picker.rs index 5e132468d0a357ff3fcbbb87347056df6a55b54d..1318b03cce0722a647ba8f3dd86c580336719d49 100644 --- a/crates/assistant2/src/context_picker/file_context_picker.rs +++ b/crates/assistant2/src/context_picker/file_context_picker.rs @@ -202,7 +202,7 @@ impl PickerDelegate for FileContextPickerDelegate { }; let path = mat.path.clone(); - if self + let already_included = self .context_store .update(cx, |context_store, _cx| { match context_store.included_file(&path) { @@ -214,8 +214,8 @@ impl PickerDelegate for FileContextPickerDelegate { None => false, } }) - .unwrap_or(true) - { + .unwrap_or(true); + if already_included { return; }