From 93ceb89c0c0352fd30f66941f820cc201391c3dd Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 9 Feb 2024 18:05:14 +0100 Subject: [PATCH] Never show whitespace-only Copilot suggestions (#7623) Fixes https://github.com/zed-industries/zed/issues/7582 Release Notes: - Fixed a bug that caused Copilot to suggest leading indentation even after the user accepted/discarded a suggestion ([#7582](https://github.com/zed-industries/zed/issues/7582)) Co-authored-by: Thorsten Ball Co-authored-by: Bennet --- crates/editor/src/editor.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index c49a5c8c50..a864204dc8 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -1222,7 +1222,12 @@ impl CopilotState { if completion_range.is_empty() && completion_range.start == cursor.text_anchor.to_offset(&completion_buffer) { - Some(&completion.text[prefix_len..completion.text.len() - suffix_len]) + let completion_text = &completion.text[prefix_len..completion.text.len() - suffix_len]; + if completion_text.trim().is_empty() { + None + } else { + Some(completion_text) + } } else { None }