From 17ff67dd7e874ad7cff5251684fb242c4a4e3200 Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 10 Jul 2020 15:41:41 +0800 Subject: Only take first 500 syntax errors Too many syntax errors make some editor/ide slow, fix #3434. --- crates/ra_ide/src/diagnostics.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide/src') diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index e69e9b4ec..71fd45e5d 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs @@ -35,7 +35,8 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec let parse = db.parse(file_id); let mut res = Vec::new(); - res.extend(parse.errors().iter().map(|err| Diagnostic { + // [#34344] Only take first 500 errors to prevent slowing down editor/ide, the number 500 is chosen arbitrarily. + res.extend(parse.errors().iter().take(500).map(|err| Diagnostic { range: err.range(), message: format!("Syntax Error: {}", err), severity: Severity::Error, -- cgit v1.2.3