diff options
Diffstat (limited to 'support/texlab/crates/texlab/src/features')
6 files changed, 14 insertions, 12 deletions
diff --git a/support/texlab/crates/texlab/src/features/completion/builder.rs b/support/texlab/crates/texlab/src/features/completion/builder.rs index b325cd183b..bae7ebbfb7 100644 --- a/support/texlab/crates/texlab/src/features/completion/builder.rs +++ b/support/texlab/crates/texlab/src/features/completion/builder.rs @@ -51,7 +51,7 @@ impl<'a> CompletionBuilder<'a> { ) -> Self { let items = Vec::new(); let matcher: Box<dyn Matcher> = match context.workspace.config().completion.matcher { - MatchingAlgo::Skim => Box::new(SkimMatcherV2::default()), + MatchingAlgo::Skim => Box::<SkimMatcherV2>::default(), MatchingAlgo::SkimIgnoreCase => Box::new(SkimMatcherV2::default().ignore_case()), MatchingAlgo::Prefix => Box::new(matcher::Prefix), MatchingAlgo::PrefixIgnoreCase => Box::new(matcher::PrefixIgnoreCase), @@ -290,7 +290,7 @@ impl<'a> CompletionBuilder<'a> { ) -> Option<()> { let score = self .matcher - .score(&entry_type.name, &self.text_pattern[1..])?; + .score(entry_type.name, &self.text_pattern[1..])?; self.items.push(Item { range, @@ -303,7 +303,7 @@ impl<'a> CompletionBuilder<'a> { } pub fn field(&mut self, range: TextRange, field: &'a BibtexFieldType<'a>) -> Option<()> { - let score = self.matcher.score(&field.name, &self.text_pattern)?; + let score = self.matcher.score(field.name, &self.text_pattern)?; self.items.push(Item { range, data: Data::Field { field }, @@ -750,8 +750,8 @@ enum Data<'a> { impl<'db> Data<'db> { pub fn label<'this: 'db>(&'this self) -> &'db str { match self { - Self::EntryType { entry_type } => &entry_type.name, - Self::Field { field } => &field.name, + Self::EntryType { entry_type } => entry_type.name, + Self::Field { field } => field.name, Self::Argument { name, .. } => name, Self::BeginSnippet => "begin", Self::Citation { key, .. } => key, diff --git a/support/texlab/crates/texlab/src/features/completion/label.rs b/support/texlab/crates/texlab/src/features/completion/label.rs index 800c7b7581..be6e1b9ab7 100644 --- a/support/texlab/crates/texlab/src/features/completion/label.rs +++ b/support/texlab/crates/texlab/src/features/completion/label.rs @@ -40,7 +40,7 @@ pub fn complete<'db>( let header = rendered_label.detail(); let footer = match &rendered_label.object { - RenderedObject::Float { caption, .. } => Some(caption.clone()), + RenderedObject::Float { caption, .. } => Some(*caption), _ => None, }; diff --git a/support/texlab/crates/texlab/src/features/completion/matcher.rs b/support/texlab/crates/texlab/src/features/completion/matcher.rs index a2b1a45e6a..5d5c93b2b9 100644 --- a/support/texlab/crates/texlab/src/features/completion/matcher.rs +++ b/support/texlab/crates/texlab/src/features/completion/matcher.rs @@ -37,6 +37,6 @@ impl Matcher for PrefixIgnoreCase { } } - return Some(-(choice.len() as i32)); + Some(-(choice.len() as i32)) } } diff --git a/support/texlab/crates/texlab/src/features/formatting/latexindent.rs b/support/texlab/crates/texlab/src/features/formatting/latexindent.rs index c269550b74..bf5385401b 100644 --- a/support/texlab/crates/texlab/src/features/formatting/latexindent.rs +++ b/support/texlab/crates/texlab/src/features/formatting/latexindent.rs @@ -5,8 +5,8 @@ use std::{ use base_db::{Document, LatexIndentConfig, Workspace}; use distro::Language; -use lsp_types::TextEdit; -use rowan::{TextLen, TextRange}; +use lsp_types::{Position, TextEdit}; +use rowan::TextLen; use tempfile::tempdir; use crate::util::line_index_ext::LineIndexExt; @@ -51,8 +51,10 @@ pub fn format_with_latexindent( None } else { let line_index = &document.line_index; + let start = Position::new(0, 0); + let end = line_index.line_col_lsp(old_text.text_len()); Some(vec![TextEdit { - range: line_index.line_col_lsp_range(TextRange::new(0.into(), old_text.text_len())), + range: lsp_types::Range::new(start, end), new_text, }]) } diff --git a/support/texlab/crates/texlab/src/features/inlay_hint.rs b/support/texlab/crates/texlab/src/features/inlay_hint.rs index 40e2984ab8..14a53ae21d 100644 --- a/support/texlab/crates/texlab/src/features/inlay_hint.rs +++ b/support/texlab/crates/texlab/src/features/inlay_hint.rs @@ -36,7 +36,7 @@ impl<'db> InlayHintBuilder<'db> { let position = self.document.line_index.line_col_lsp(offset); self.hints.push(InlayHint { position, - label: InlayHintLabel::String(text), + label: InlayHintLabel::String(format!(" {text} ")), kind: None, text_edits: None, tooltip: None, diff --git a/support/texlab/crates/texlab/src/features/inlay_hint/label.rs b/support/texlab/crates/texlab/src/features/inlay_hint/label.rs index dd33990f45..f73d3fd9ae 100644 --- a/support/texlab/crates/texlab/src/features/inlay_hint/label.rs +++ b/support/texlab/crates/texlab/src/features/inlay_hint/label.rs @@ -34,7 +34,7 @@ pub(super) fn find_hints(builder: &mut InlayHintBuilder) -> Option<()> { RenderedObject::EnumItem => format!("Item {}", number), }; - builder.push(label.name.range.end(), text); + builder.push(label.full_range.end(), text); } Some(()) |