aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorPhilipp Mildenberger2023-03-20 00:18:08 +0000
committerPhilipp Mildenberger2023-05-18 19:58:17 +0000
commit451fe528bbc71e2712c02c1ee0d7ac6fcc1a058b (patch)
tree03cbf0b1555b66d447b255d9f98c6cfc2d90cc46 /helix-term
parent8ee599942a0e5ff6fa1a908ca076785e0d2bd0c7 (diff)
Filter out already seen language servers in requests that can be sent to multiple language servers (code-action, completion, symbol pickers)
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs3
-rw-r--r--helix-term/src/commands/lsp.rs15
2 files changed, 17 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index e2a5975b..d602eaa2 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4243,9 +4243,12 @@ pub fn completion(cx: &mut Context) {
let text = savepoint.text.clone();
let cursor = savepoint.cursor();
+ let mut seen_language_servers = HashSet::new();
+
let mut futures: FuturesUnordered<_> = doc
.language_servers_with_feature(LanguageServerFeature::Completion)
// TODO this should probably already been filtered in something like "language_servers_with_feature"
+ .filter(|ls| seen_language_servers.insert(ls.id()))
.filter_map(|language_server| {
let language_server_id = language_server.id();
let offset_encoding = language_server.offset_encoding();
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index a1bd291c..6a024bed 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -37,7 +37,12 @@ use crate::{
};
use std::{
- cmp::Ordering, collections::BTreeMap, fmt::Write, future::Future, path::PathBuf, sync::Arc,
+ cmp::Ordering,
+ collections::{BTreeMap, HashSet},
+ fmt::Write,
+ future::Future,
+ path::PathBuf,
+ sync::Arc,
};
impl ui::menu::Item for lsp::Location {
@@ -351,8 +356,11 @@ pub fn symbol_picker(cx: &mut Context) {
}
let doc = doc!(cx.editor);
+ let mut seen_language_servers = HashSet::new();
+
let mut futures: FuturesUnordered<_> = doc
.language_servers_with_feature(LanguageServerFeature::DocumentSymbols)
+ .filter(|ls| seen_language_servers.insert(ls.id()))
.filter_map(|ls| {
let request = ls.document_symbols(doc.identifier())?;
Some((request, ls.offset_encoding(), doc.identifier()))
@@ -413,8 +421,10 @@ pub fn workspace_symbol_picker(cx: &mut Context) {
let get_symbols = move |pattern: String, editor: &mut Editor| {
let doc = doc!(editor);
+ let mut seen_language_servers = HashSet::new();
let mut futures: FuturesUnordered<_> = doc
.language_servers_with_feature(LanguageServerFeature::WorkspaceSymbols)
+ .filter(|ls| seen_language_servers.insert(ls.id()))
.filter_map(|ls| Some((ls.workspace_symbols(pattern.clone())?, ls.offset_encoding())))
.map(|(request, offset_encoding)| async move {
let json = request.await?;
@@ -573,8 +583,11 @@ pub fn code_action(cx: &mut Context) {
let selection_range = doc.selection(view.id).primary();
+ let mut seen_language_servers = HashSet::new();
+
let mut futures: FuturesUnordered<_> = doc
.language_servers_with_feature(LanguageServerFeature::CodeAction)
+ .filter(|ls| seen_language_servers.insert(ls.id()))
// TODO this should probably already been filtered in something like "language_servers_with_feature"
.filter_map(|language_server| {
let offset_encoding = language_server.offset_encoding();