sum_tree: Replace rayon with futures (#41586)
Release Notes: - N/A *or* Added/Fixed/Improved ... Co-authored by: Kate <kate@zed.dev>
This commit is contained in:
@@ -189,7 +189,7 @@ impl super::LspAdapter for CLspAdapter {
|
||||
Some(lsp::CompletionItemKind::FIELD) if completion.detail.is_some() => {
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let text = format!("{} {}", detail, label);
|
||||
let source = Rope::from(format!("struct S {{ {} }}", text).as_str());
|
||||
let source = Rope::from_str_small(format!("struct S {{ {} }}", text).as_str());
|
||||
let runs = language.highlight_text(&source, 11..11 + text.len());
|
||||
let filter_range = completion
|
||||
.filter_text
|
||||
@@ -206,7 +206,8 @@ impl super::LspAdapter for CLspAdapter {
|
||||
{
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let text = format!("{} {}", detail, label);
|
||||
let runs = language.highlight_text(&Rope::from(text.as_str()), 0..text.len());
|
||||
let runs =
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), 0..text.len());
|
||||
let filter_range = completion
|
||||
.filter_text
|
||||
.as_deref()
|
||||
@@ -222,7 +223,8 @@ impl super::LspAdapter for CLspAdapter {
|
||||
{
|
||||
let detail = completion.detail.as_ref().unwrap();
|
||||
let text = format!("{} {}", detail, label);
|
||||
let runs = language.highlight_text(&Rope::from(text.as_str()), 0..text.len());
|
||||
let runs =
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), 0..text.len());
|
||||
let filter_range = completion
|
||||
.filter_text
|
||||
.as_deref()
|
||||
@@ -326,7 +328,7 @@ impl super::LspAdapter for CLspAdapter {
|
||||
Some(CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ impl LspAdapter for GoLspAdapter {
|
||||
match completion.kind.zip(completion.detail.as_ref()) {
|
||||
Some((lsp::CompletionItemKind::MODULE, detail)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
let source = Rope::from(format!("import {text}").as_str());
|
||||
let source = Rope::from_str_small(format!("import {text}").as_str());
|
||||
let runs = language.highlight_text(&source, 7..7 + text[name_offset..].len());
|
||||
let filter_range = completion
|
||||
.filter_text
|
||||
@@ -238,8 +238,9 @@ impl LspAdapter for GoLspAdapter {
|
||||
detail,
|
||||
)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
let source =
|
||||
Rope::from(format!("var {} {}", &text[name_offset..], detail).as_str());
|
||||
let source = Rope::from_str_small(
|
||||
format!("var {} {}", &text[name_offset..], detail).as_str(),
|
||||
);
|
||||
let runs = adjust_runs(
|
||||
name_offset,
|
||||
language.highlight_text(&source, 4..4 + text[name_offset..].len()),
|
||||
@@ -256,7 +257,8 @@ impl LspAdapter for GoLspAdapter {
|
||||
}
|
||||
Some((lsp::CompletionItemKind::STRUCT, _)) => {
|
||||
let text = format!("{label} struct {{}}");
|
||||
let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
|
||||
let source =
|
||||
Rope::from_str_small(format!("type {}", &text[name_offset..]).as_str());
|
||||
let runs = adjust_runs(
|
||||
name_offset,
|
||||
language.highlight_text(&source, 5..5 + text[name_offset..].len()),
|
||||
@@ -273,7 +275,8 @@ impl LspAdapter for GoLspAdapter {
|
||||
}
|
||||
Some((lsp::CompletionItemKind::INTERFACE, _)) => {
|
||||
let text = format!("{label} interface {{}}");
|
||||
let source = Rope::from(format!("type {}", &text[name_offset..]).as_str());
|
||||
let source =
|
||||
Rope::from_str_small(format!("type {}", &text[name_offset..]).as_str());
|
||||
let runs = adjust_runs(
|
||||
name_offset,
|
||||
language.highlight_text(&source, 5..5 + text[name_offset..].len()),
|
||||
@@ -290,8 +293,9 @@ impl LspAdapter for GoLspAdapter {
|
||||
}
|
||||
Some((lsp::CompletionItemKind::FIELD, detail)) => {
|
||||
let text = format!("{label} {detail}");
|
||||
let source =
|
||||
Rope::from(format!("type T struct {{ {} }}", &text[name_offset..]).as_str());
|
||||
let source = Rope::from_str_small(
|
||||
format!("type T struct {{ {} }}", &text[name_offset..]).as_str(),
|
||||
);
|
||||
let runs = adjust_runs(
|
||||
name_offset,
|
||||
language.highlight_text(&source, 16..16 + text[name_offset..].len()),
|
||||
@@ -309,7 +313,9 @@ impl LspAdapter for GoLspAdapter {
|
||||
Some((lsp::CompletionItemKind::FUNCTION | lsp::CompletionItemKind::METHOD, detail)) => {
|
||||
if let Some(signature) = detail.strip_prefix("func") {
|
||||
let text = format!("{label}{signature}");
|
||||
let source = Rope::from(format!("func {} {{}}", &text[name_offset..]).as_str());
|
||||
let source = Rope::from_str_small(
|
||||
format!("func {} {{}}", &text[name_offset..]).as_str(),
|
||||
);
|
||||
let runs = adjust_runs(
|
||||
name_offset,
|
||||
language.highlight_text(&source, 5..5 + text[name_offset..].len()),
|
||||
@@ -385,7 +391,7 @@ impl LspAdapter for GoLspAdapter {
|
||||
Some(CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ use pet_core::python_environment::{PythonEnvironment, PythonEnvironmentKind};
|
||||
use pet_virtualenv::is_virtualenv_dir;
|
||||
use project::Fs;
|
||||
use project::lsp_store::language_server_settings;
|
||||
use rope::Rope;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Value, json};
|
||||
use smol::lock::OnceCell;
|
||||
@@ -466,7 +467,7 @@ impl LspAdapter for PyrightLspAdapter {
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1511,7 +1512,7 @@ impl LspAdapter for PyLspAdapter {
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -1800,7 +1801,7 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
Some(language::CodeLabel::new(
|
||||
text[display_range.clone()].to_string(),
|
||||
filter_range,
|
||||
language.highlight_text(&text.as_str().into(), display_range),
|
||||
language.highlight_text(&Rope::from_str_small(text.as_str()), display_range),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ impl LspAdapter for RustLspAdapter {
|
||||
let name = &completion.label;
|
||||
let text = format!("{name}: {signature}");
|
||||
let prefix = "struct S { ";
|
||||
let source = Rope::from_iter([prefix, &text, " }"]);
|
||||
let source = Rope::from_iter_small([prefix, &text, " }"]);
|
||||
let runs =
|
||||
language.highlight_text(&source, prefix.len()..prefix.len() + text.len());
|
||||
mk_label(text, &|| 0..completion.label.len(), runs)
|
||||
@@ -264,7 +264,7 @@ impl LspAdapter for RustLspAdapter {
|
||||
let name = &completion.label;
|
||||
let text = format!("{name}: {signature}",);
|
||||
let prefix = "let ";
|
||||
let source = Rope::from_iter([prefix, &text, " = ();"]);
|
||||
let source = Rope::from_iter_small([prefix, &text, " = ();"]);
|
||||
let runs =
|
||||
language.highlight_text(&source, prefix.len()..prefix.len() + text.len());
|
||||
mk_label(text, &|| 0..completion.label.len(), runs)
|
||||
@@ -302,7 +302,7 @@ impl LspAdapter for RustLspAdapter {
|
||||
.filter(|it| it.contains(&label))
|
||||
.and_then(|it| Some((it, FULL_SIGNATURE_REGEX.find(it)?)))
|
||||
{
|
||||
let source = Rope::from(function_signature);
|
||||
let source = Rope::from_str_small(function_signature);
|
||||
let runs = language.highlight_text(&source, 0..function_signature.len());
|
||||
mk_label(
|
||||
function_signature.to_owned(),
|
||||
@@ -311,7 +311,7 @@ impl LspAdapter for RustLspAdapter {
|
||||
)
|
||||
} else if let Some((prefix, suffix)) = fn_prefixed {
|
||||
let text = format!("{label}{suffix}");
|
||||
let source = Rope::from_iter([prefix, " ", &text, " {}"]);
|
||||
let source = Rope::from_iter_small([prefix, " ", &text, " {}"]);
|
||||
let run_start = prefix.len() + 1;
|
||||
let runs = language.highlight_text(&source, run_start..run_start + text.len());
|
||||
mk_label(text, &|| 0..label.len(), runs)
|
||||
@@ -322,7 +322,7 @@ impl LspAdapter for RustLspAdapter {
|
||||
{
|
||||
let text = completion.label.clone();
|
||||
let len = text.len();
|
||||
let source = Rope::from(text.as_str());
|
||||
let source = Rope::from_str_small(text.as_str());
|
||||
let runs = language.highlight_text(&source, 0..len);
|
||||
mk_label(text, &|| 0..completion.label.len(), runs)
|
||||
} else if detail_left.is_none() {
|
||||
@@ -399,7 +399,10 @@ impl LspAdapter for RustLspAdapter {
|
||||
Some(CodeLabel::new(
|
||||
format!("{prefix}{name}"),
|
||||
filter_range,
|
||||
language.highlight_text(&Rope::from_iter([prefix, name, suffix]), display_range),
|
||||
language.highlight_text(
|
||||
&Rope::from_iter_small([prefix, name, suffix]),
|
||||
display_range,
|
||||
),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user