From b0a9c644494eae9994214c09916cf65213c9d74e Mon Sep 17 00:00:00 2001 From: Dhruv Manilawala Date: Tue, 2 Jul 2024 16:31:48 +0530 Subject: [PATCH] Avoid syntax error notification for source code actions --- crates/ruff_server/src/fix.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/ruff_server/src/fix.rs b/crates/ruff_server/src/fix.rs index 6690279da020ae..b1c7a61fe6bd5b 100644 --- a/crates/ruff_server/src/fix.rs +++ b/crates/ruff_server/src/fix.rs @@ -69,8 +69,7 @@ pub(crate) fn fix_all( let FixerResult { transformed, result: LinterResult { - has_syntax_error: has_error, - .. + has_syntax_error, .. }, .. } = ruff_linter::linter::lint_fix( @@ -83,9 +82,9 @@ pub(crate) fn fix_all( source_type, )?; - if has_error { - // abort early if a parsing error occurred - return Err(anyhow::anyhow!("A parsing error occurred during `fix_all`")); + if has_syntax_error { + // If there's a syntax error, then there won't be any fixes to apply. + return Ok(Fixes::default()); } // fast path: if `transformed` is still borrowed, no changes were made and we can return early