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 <thorsten@zed.dev>
Co-authored-by: Bennet <bennetbo@gmx.de>
This commit is contained in:
Antonio Scandurra 2024-02-09 18:05:14 +01:00 committed by GitHub
parent ad97e447f5
commit 93ceb89c0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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
}