Avoid cloning diagnostic messages from language server
This commit is contained in:
parent
8492c6e7ac
commit
699dafbbd4
1 changed files with 4 additions and 3 deletions
|
@ -34,6 +34,7 @@ use std::{
|
||||||
ffi::{OsStr, OsString},
|
ffi::{OsStr, OsString},
|
||||||
fmt,
|
fmt,
|
||||||
future::Future,
|
future::Future,
|
||||||
|
mem,
|
||||||
ops::{Deref, Range},
|
ops::{Deref, Range},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{
|
sync::{
|
||||||
|
@ -671,7 +672,7 @@ impl Worktree {
|
||||||
|
|
||||||
fn update_diagnostics(
|
fn update_diagnostics(
|
||||||
&mut self,
|
&mut self,
|
||||||
params: lsp::PublishDiagnosticsParams,
|
mut params: lsp::PublishDiagnosticsParams,
|
||||||
cx: &mut ModelContext<Worktree>,
|
cx: &mut ModelContext<Worktree>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let this = self.as_local_mut().ok_or_else(|| anyhow!("not local"))?;
|
let this = self.as_local_mut().ok_or_else(|| anyhow!("not local"))?;
|
||||||
|
@ -688,7 +689,7 @@ impl Worktree {
|
||||||
let mut group_ids_by_diagnostic_range = HashMap::default();
|
let mut group_ids_by_diagnostic_range = HashMap::default();
|
||||||
let mut diagnostics_by_group_id = HashMap::default();
|
let mut diagnostics_by_group_id = HashMap::default();
|
||||||
let mut next_group_id = 0;
|
let mut next_group_id = 0;
|
||||||
for diagnostic in ¶ms.diagnostics {
|
for diagnostic in &mut params.diagnostics {
|
||||||
let source = diagnostic.source.as_ref();
|
let source = diagnostic.source.as_ref();
|
||||||
let code = diagnostic.code.as_ref();
|
let code = diagnostic.code.as_ref();
|
||||||
let group_id = diagnostic_ranges(&diagnostic, &abs_path)
|
let group_id = diagnostic_ranges(&diagnostic, &abs_path)
|
||||||
|
@ -715,7 +716,7 @@ impl Worktree {
|
||||||
lsp::NumberOrString::String(code) => code,
|
lsp::NumberOrString::String(code) => code,
|
||||||
}),
|
}),
|
||||||
severity: diagnostic.severity.unwrap_or(DiagnosticSeverity::ERROR),
|
severity: diagnostic.severity.unwrap_or(DiagnosticSeverity::ERROR),
|
||||||
message: diagnostic.message.clone(),
|
message: mem::take(&mut diagnostic.message),
|
||||||
group_id,
|
group_id,
|
||||||
is_primary: false,
|
is_primary: false,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue