aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/view.rs')
-rw-r--r--helix-view/src/view.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/helix-view/src/view.rs b/helix-view/src/view.rs
index e5e2641a..bbdc74a7 100644
--- a/helix-view/src/view.rs
+++ b/helix-view/src/view.rs
@@ -19,7 +19,6 @@ use helix_core::{
use std::{
collections::{HashMap, VecDeque},
fmt,
- rc::Rc,
};
const JUMP_LIST_CAPACITY: usize = 30;
@@ -409,10 +408,12 @@ impl View {
}
/// Get the text annotations to display in the current view for the given document and theme.
- pub fn text_annotations(&self, doc: &Document, theme: Option<&Theme>) -> TextAnnotations {
- // TODO custom annotations for custom views like side by side diffs
-
- let mut text_annotations = doc.text_annotations(theme);
+ pub fn text_annotations<'a>(
+ &self,
+ doc: &'a Document,
+ theme: Option<&Theme>,
+ ) -> TextAnnotations<'a> {
+ let mut text_annotations = TextAnnotations::default();
let DocumentInlayHints {
id: _,
@@ -436,20 +437,15 @@ impl View {
.and_then(|t| t.find_scope_index("ui.virtual.inlay-hint"))
.map(Highlight);
- let mut add_annotations = |annotations: &Rc<[_]>, style| {
- if !annotations.is_empty() {
- text_annotations.add_inline_annotations(Rc::clone(annotations), style);
- }
- };
-
// Overlapping annotations are ignored apart from the first so the order here is not random:
// types -> parameters -> others should hopefully be the "correct" order for most use cases,
// with the padding coming before and after as expected.
- add_annotations(padding_before_inlay_hints, None);
- add_annotations(type_inlay_hints, type_style);
- add_annotations(parameter_inlay_hints, parameter_style);
- add_annotations(other_inlay_hints, other_style);
- add_annotations(padding_after_inlay_hints, None);
+ text_annotations
+ .add_inline_annotations(padding_before_inlay_hints, None)
+ .add_inline_annotations(type_inlay_hints, type_style)
+ .add_inline_annotations(parameter_inlay_hints, parameter_style)
+ .add_inline_annotations(other_inlay_hints, other_style)
+ .add_inline_annotations(padding_after_inlay_hints, None);
text_annotations
}