Only take first 500 syntax errors

Too many syntax errors make some editor/ide slow, fix #3434.
This commit is contained in:
yihuang 2020-07-10 15:41:41 +08:00
parent 5fc84f071d
commit 17ff67dd7e
No known key found for this signature in database
GPG key ID: B0E508BA8BD63494

View file

@ -35,7 +35,8 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic>
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,