summaryrefslogtreecommitdiff
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.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 6473c2d1..93b83da4 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -36,6 +36,7 @@ use helix_core::{
};
use crate::editor::Config;
+use crate::events::{DocumentDidChange, SelectionDidChange};
use crate::{DocumentId, Editor, Theme, View, ViewId};
/// 8kB of buffer space for encoding and decoding `Rope`s.
@@ -1096,6 +1097,10 @@ impl Document {
// TODO: use a transaction?
self.selections
.insert(view_id, selection.ensure_invariants(self.text().slice(..)));
+ helix_event::dispatch(SelectionDidChange {
+ doc: self,
+ view: view_id,
+ })
}
/// Find the origin selection of the text in a document, i.e. where
@@ -1149,6 +1154,14 @@ impl Document {
let success = transaction.changes().apply(&mut self.text);
if success {
+ if emit_lsp_notification {
+ helix_event::dispatch(DocumentDidChange {
+ doc: self,
+ view: view_id,
+ old_text: &old_doc,
+ });
+ }
+
for selection in self.selections.values_mut() {
*selection = selection
.clone()
@@ -1164,6 +1177,10 @@ impl Document {
view_id,
selection.clone().ensure_invariants(self.text.slice(..)),
);
+ helix_event::dispatch(SelectionDidChange {
+ doc: self,
+ view: view_id,
+ });
}
self.modified_since_accessed = true;
@@ -1276,6 +1293,7 @@ impl Document {
}
if emit_lsp_notification {
+ // TODO: move to hook
// emit lsp notification
for language_server in self.language_servers() {
let notify = language_server.text_document_did_change(