aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs42
1 files changed, 17 insertions, 25 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index f813c742..090e4dd5 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -8,7 +8,7 @@ use helix_core::chars::char_is_word;
use helix_core::doc_formatter::TextFormat;
use helix_core::encoding::Encoding;
use helix_core::syntax::{Highlight, LanguageServerFeature};
-use helix_core::text_annotations::{InlineAnnotation, TextAnnotations};
+use helix_core::text_annotations::InlineAnnotation;
use helix_lsp::util::lsp_pos_to_pos;
use helix_vcs::{DiffHandle, DiffProviderRegistry};
@@ -21,7 +21,6 @@ use std::collections::HashMap;
use std::fmt::Display;
use std::future::Future;
use std::path::{Path, PathBuf};
-use std::rc::Rc;
use std::str::FromStr;
use std::sync::{Arc, Weak};
use std::time::SystemTime;
@@ -200,22 +199,22 @@ pub struct DocumentInlayHints {
pub id: DocumentInlayHintsId,
/// Inlay hints of `TYPE` kind, if any.
- pub type_inlay_hints: Rc<[InlineAnnotation]>,
+ pub type_inlay_hints: Vec<InlineAnnotation>,
/// Inlay hints of `PARAMETER` kind, if any.
- pub parameter_inlay_hints: Rc<[InlineAnnotation]>,
+ pub parameter_inlay_hints: Vec<InlineAnnotation>,
/// Inlay hints that are neither `TYPE` nor `PARAMETER`.
///
/// LSPs are not required to associate a kind to their inlay hints, for example Rust-Analyzer
/// currently never does (February 2023) and the LSP spec may add new kinds in the future that
/// we want to display even if we don't have some special highlighting for them.
- pub other_inlay_hints: Rc<[InlineAnnotation]>,
+ pub other_inlay_hints: Vec<InlineAnnotation>,
/// Inlay hint padding. When creating the final `TextAnnotations`, the `before` padding must be
/// added first, then the regular inlay hints, then the `after` padding.
- pub padding_before_inlay_hints: Rc<[InlineAnnotation]>,
- pub padding_after_inlay_hints: Rc<[InlineAnnotation]>,
+ pub padding_before_inlay_hints: Vec<InlineAnnotation>,
+ pub padding_after_inlay_hints: Vec<InlineAnnotation>,
}
impl DocumentInlayHints {
@@ -223,11 +222,11 @@ impl DocumentInlayHints {
pub fn empty_with_id(id: DocumentInlayHintsId) -> Self {
Self {
id,
- type_inlay_hints: Rc::new([]),
- parameter_inlay_hints: Rc::new([]),
- other_inlay_hints: Rc::new([]),
- padding_before_inlay_hints: Rc::new([]),
- padding_after_inlay_hints: Rc::new([]),
+ type_inlay_hints: Vec::new(),
+ parameter_inlay_hints: Vec::new(),
+ other_inlay_hints: Vec::new(),
+ padding_before_inlay_hints: Vec::new(),
+ padding_after_inlay_hints: Vec::new(),
}
}
}
@@ -1266,13 +1265,12 @@ impl Document {
});
// Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place
- let apply_inlay_hint_changes = |annotations: &mut Rc<[InlineAnnotation]>| {
- if let Some(data) = Rc::get_mut(annotations) {
- changes.update_positions(
- data.iter_mut()
- .map(|annotation| (&mut annotation.char_idx, Assoc::After)),
- );
- }
+ let apply_inlay_hint_changes = |annotations: &mut Vec<InlineAnnotation>| {
+ changes.update_positions(
+ annotations
+ .iter_mut()
+ .map(|annotation| (&mut annotation.char_idx, Assoc::After)),
+ );
};
self.inlay_hints_oudated = true;
@@ -1940,12 +1938,6 @@ impl Document {
}
}
- /// Get the text annotations that apply to the whole document, those that do not apply to any
- /// specific view.
- pub fn text_annotations(&self, _theme: Option<&Theme>) -> TextAnnotations {
- TextAnnotations::default()
- }
-
/// Set the inlay hints for this document and `view_id`.
pub fn set_inlay_hints(&mut self, view_id: ViewId, inlay_hints: DocumentInlayHints) {
self.inlay_hints.insert(view_id, inlay_hints);