Use proper editor name

This commit is contained in:
Kirill Bulatov 2023-09-19 23:34:43 +03:00
parent 184119258e
commit f9fac02c57
3 changed files with 16 additions and 15 deletions

View File

@ -190,10 +190,10 @@ fn run_server() -> anyhow::Result<()> {
}
};
let mut is_visual_studio = false;
let mut is_visual_studio_code = false;
if let Some(client_info) = client_info {
tracing::info!("Client '{}' {}", client_info.name, client_info.version.unwrap_or_default());
is_visual_studio = client_info.name == "Visual Studio Code";
is_visual_studio_code = client_info.name == "Visual Studio Code";
}
let workspace_roots = workspace_folders
@ -207,7 +207,7 @@ fn run_server() -> anyhow::Result<()> {
})
.filter(|workspaces| !workspaces.is_empty())
.unwrap_or_else(|| vec![root_path.clone()]);
let mut config = Config::new(root_path, capabilities, workspace_roots, is_visual_studio);
let mut config = Config::new(root_path, capabilities, workspace_roots, is_visual_studio_code);
if let Some(json) = initialization_options {
if let Err(e) = config.update(json) {
use lsp_types::{

View File

@ -565,7 +565,7 @@ pub struct Config {
data: ConfigData,
detached_files: Vec<AbsPathBuf>,
snippets: Vec<Snippet>,
is_visual_studio: bool,
is_visual_studio_code: bool,
}
type ParallelCachePrimingNumThreads = u8;
@ -761,7 +761,7 @@ pub fn new(
root_path: AbsPathBuf,
caps: ClientCapabilities,
workspace_roots: Vec<AbsPathBuf>,
is_visual_studio: bool,
is_visual_studio_code: bool,
) -> Self {
Config {
caps,
@ -771,7 +771,7 @@ pub fn new(
root_path,
snippets: Default::default(),
workspace_roots,
is_visual_studio,
is_visual_studio_code,
}
}
@ -1673,8 +1673,8 @@ pub fn typing_autoclose_angle(&self) -> bool {
// FIXME: VSCode seems to work wrong sometimes, see https://github.com/microsoft/vscode/issues/193124
// hence, distinguish it for now.
pub fn is_visual_studio(&self) -> bool {
self.is_visual_studio
pub fn is_visual_studio_code(&self) -> bool {
self.is_visual_studio_code
}
}
// Deserialization definitions

View File

@ -443,16 +443,17 @@ pub(crate) fn inlay_hint(
file_id: FileId,
inlay_hint: InlayHint,
) -> Cancellable<lsp_types::InlayHint> {
let is_visual_studio = snap.config.is_visual_studio();
let is_visual_studio_code = snap.config.is_visual_studio_code();
let needs_resolve = inlay_hint.needs_resolve;
let (label, tooltip, mut something_to_resolve) =
inlay_hint_label(snap, fields_to_resolve, needs_resolve, inlay_hint.label)?;
let text_edits = if !is_visual_studio && needs_resolve && fields_to_resolve.resolve_text_edits {
something_to_resolve |= inlay_hint.text_edit.is_some();
None
} else {
inlay_hint.text_edit.map(|it| text_edit_vec(line_index, it))
};
let text_edits =
if !is_visual_studio_code && needs_resolve && fields_to_resolve.resolve_text_edits {
something_to_resolve |= inlay_hint.text_edit.is_some();
None
} else {
inlay_hint.text_edit.map(|it| text_edit_vec(line_index, it))
};
let data = if needs_resolve && something_to_resolve {
Some(to_value(lsp_ext::InlayHintResolveData { file_id: file_id.0 }).unwrap())
} else {