From 1dad166b3cb710b4aa32b8c21b91dbca02b2e408 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 7 Jan 2021 03:03:02 +0000 Subject: CTAN sync 202101070303 --- support/texlab/src/server.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'support/texlab/src/server.rs') diff --git a/support/texlab/src/server.rs b/support/texlab/src/server.rs index e22fe4f5c9..9c5e1b857b 100644 --- a/support/texlab/src/server.rs +++ b/support/texlab/src/server.rs @@ -3,7 +3,7 @@ use crate::citeproc::render_citation; use crate::{ build::BuildProvider, - completion::{CompletionItemData, CompletionProvider}, + completion::{CompletionItemData, CompletionProvider, COMPLETION_LIMIT}, components::COMPONENT_DATABASE, config::ConfigManager, definition::DefinitionProvider, @@ -35,6 +35,7 @@ pub struct LatexLspServer { distro: Arc, client: Arc, client_capabilities: OnceCell>, + client_info: OnceCell>, current_dir: Arc, config_manager: OnceCell>, action_manager: ActionManager, @@ -62,6 +63,7 @@ impl LatexLspServer { distro, client: Arc::clone(&client), client_capabilities: OnceCell::new(), + client_info: OnceCell::new(), current_dir, config_manager: OnceCell::new(), action_manager: ActionManager::default(), @@ -102,6 +104,10 @@ impl LatexLspServer { .set(Arc::new(params.capabilities)) .expect("initialize was called two times"); + self.client_info + .set(params.client_info) + .expect("initialize was called two times"); + let _ = self.config_manager.set(ConfigManager::new( Arc::clone(&self.client), self.client_capabilities(), @@ -253,9 +259,23 @@ impl LatexLspServer { req.params.text_document_position.position, ); + let items = self.completion_provider.execute(&req).await; + let is_incomplete = if self + .client_info + .get() + .and_then(|info| info.as_ref()) + .map(|info| info.name.as_str()) + .unwrap_or_default() + == "vscode" + { + true + } else { + items.len() >= COMPLETION_LIMIT + }; + Ok(CompletionList { - is_incomplete: true, - items: self.completion_provider.execute(&req).await, + is_incomplete, + items, }) } -- cgit v1.2.3