Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs41
1 files changed, 9 insertions, 32 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 41c9ee1e..7dde7985 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -148,9 +148,6 @@ pub struct Document {
/// To know if they're up-to-date, check the `id` field in `DocumentInlayHints`.
pub(crate) inlay_hints: HashMap<ViewId, DocumentInlayHints>,
pub(crate) jump_labels: HashMap<ViewId, Vec<Overlay>>,
- /// Set to `true` when the document is updated, reset to `false` on the next inlay hints
- /// update from the LSP
- pub inlay_hints_oudated: bool,
path: Option<PathBuf>,
relative_path: OnceCell<Option<PathBuf>>,
@@ -207,6 +204,8 @@ pub struct Document {
// NOTE: ideally this would live on the handler for color swatches. This is blocked on a
// large refactor that would make `&mut Editor` available on the `DocumentDidChange` event.
pub color_swatch_controller: TaskController,
+ // NOTE: ideally this would live on the handler for inlay hints, see the comment above.
+ pub inlay_hint_controllers: HashMap<ViewId, TaskController>,
}
#[derive(Debug, Clone, Default)]
@@ -290,7 +289,6 @@ impl fmt::Debug for Document {
.field("id", &self.id)
.field("text", &self.text)
.field("selections", &self.selections)
- .field("inlay_hints_oudated", &self.inlay_hints_oudated)
.field("text_annotations", &self.inlay_hints)
.field("view_data", &self.view_data)
.field("path", &self.path)
@@ -693,7 +691,7 @@ impl Document {
text,
selections: HashMap::default(),
inlay_hints: HashMap::default(),
- inlay_hints_oudated: false,
+ inlay_hint_controllers: HashMap::default(),
view_data: Default::default(),
indent_style: DEFAULT_INDENT,
editor_config: EditorConfig::default(),
@@ -1461,33 +1459,6 @@ impl Document {
)
});
- // Update the inlay hint annotations' positions, helping ensure they are displayed in the proper place
- 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;
- for text_annotation in self.inlay_hints.values_mut() {
- let DocumentInlayHints {
- id: _,
- type_inlay_hints,
- parameter_inlay_hints,
- other_inlay_hints,
- padding_before_inlay_hints,
- padding_after_inlay_hints,
- } = text_annotation;
-
- apply_inlay_hint_changes(padding_before_inlay_hints);
- apply_inlay_hint_changes(type_inlay_hints);
- apply_inlay_hint_changes(parameter_inlay_hints);
- apply_inlay_hint_changes(other_inlay_hints);
- apply_inlay_hint_changes(padding_after_inlay_hints);
- }
-
helix_event::dispatch(DocumentDidChange {
doc: self,
view: view_id,
@@ -2242,6 +2213,12 @@ impl Document {
self.inlay_hints.get(&view_id)
}
+ pub fn inlay_hints_mut(&mut self) -> impl Iterator<Item = (ViewId, &mut DocumentInlayHints)> {
+ self.inlay_hints
+ .iter_mut()
+ .map(|(view_id, hints)| (*view_id, hints))
+ }
+
/// Completely removes all the inlay hints saved for the document, dropping them to free memory
/// (since it often means inlay hints have been fully deactivated).
pub fn reset_all_inlay_hints(&mut self) {