Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect lsp definition order for code actions #9590

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions helix-term/src/commands/lsp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures_util::{stream::FuturesUnordered, FutureExt};
use futures_util::{stream::FuturesOrdered, FutureExt};
use helix_lsp::{
block_on,
lsp::{
Expand Down Expand Up @@ -339,7 +339,7 @@ pub fn symbol_picker(cx: &mut Context) {

let mut seen_language_servers = HashSet::new();

let mut futures: FuturesUnordered<_> = doc
let mut futures: FuturesOrdered<_> = doc
.language_servers_with_feature(LanguageServerFeature::DocumentSymbols)
.filter(|ls| seen_language_servers.insert(ls.id()))
.map(|language_server| {
Expand Down Expand Up @@ -414,7 +414,7 @@ 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
let mut futures: FuturesOrdered<_> = doc
.language_servers_with_feature(LanguageServerFeature::WorkspaceSymbols)
.filter(|ls| seen_language_servers.insert(ls.id()))
.map(|language_server| {
Expand Down Expand Up @@ -580,7 +580,7 @@ pub fn code_action(cx: &mut Context) {

let mut seen_language_servers = HashSet::new();

let mut futures: FuturesUnordered<_> = doc
let mut futures: FuturesOrdered<_> = 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"
Expand Down
12 changes: 6 additions & 6 deletions helix-term/src/handlers/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use std::time::Duration;

use arc_swap::ArcSwap;
use futures_util::stream::FuturesUnordered;
use futures_util::stream::FuturesOrdered;
use helix_core::chars::char_is_word;
use helix_core::syntax::LanguageServerFeature;
use helix_event::{
Expand Down Expand Up @@ -196,10 +196,10 @@ fn request_completion(
let trigger_text = text.slice(..cursor);

let mut seen_language_servers = HashSet::new();
let mut futures: FuturesUnordered<_> = doc
let mut futures: FuturesOrdered<_> = doc
.language_servers_with_feature(LanguageServerFeature::Completion)
.filter(|ls| seen_language_servers.insert(ls.id()))
.map(|ls| {
.filter_map(|ls| {
let language_server_id = ls.id();
let offset_encoding = ls.offset_encoding();
let pos = pos_to_lsp_pos(text, cursor, offset_encoding);
Expand Down Expand Up @@ -227,8 +227,8 @@ fn request_completion(
}
};

let completion_response = ls.completion(doc_id, pos, None, context).unwrap();
async move {
let completion_response = ls.completion(doc_id, pos, None, context)?;
Some(async move {
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
let json = completion_response.await?;
let response: Option<lsp::CompletionResponse> = serde_json::from_value(json)?;
let items = match response {
Expand All @@ -248,7 +248,7 @@ fn request_completion(
})
.collect();
anyhow::Ok(items)
}
})
})
.collect();

Expand Down
5 changes: 0 additions & 5 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,6 @@ impl Completion {
let language_server = language_server!(item);
let offset_encoding = language_server.offset_encoding();

let language_server = editor
.language_servers
.get_by_id(item.language_server_id)
.unwrap();

// resolve item if not yet resolved
if !item.resolved {
if let Some(resolved) =
Expand Down
Loading