summaryrefslogtreecommitdiff
path: root/helix-term/src/application.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-16 09:27:57 +0000
committerBlaž Hrastnik2021-03-22 04:53:43 +0000
commitbf95ee27aa3c9f137e34f30a01f25e4930a8b1bb (patch)
tree0867bdfc608540199f454c93e4a8d97a043036ef /helix-term/src/application.rs
parent5e6716c89c0909bc374e26bedbba703427f9aa26 (diff)
Store Document on the Editor type, make View reference it.
Diffstat (limited to 'helix-term/src/application.rs')
-rw-r--r--helix-term/src/application.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index cab7ad63..8af963a9 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -125,15 +125,16 @@ impl Application {
Notification::PublishDiagnostics(params) => {
let path = Some(params.uri.to_file_path().unwrap());
- let view = self
+ let doc = self
.editor
- .tree
- .views()
- .map(|(view, _key)| view)
- .find(|view| view.doc.path() == path.as_ref());
+ .documents
+ .iter_mut()
+ .find(|(_, doc)| doc.borrow().path() == path.as_ref());
+
+ if let Some((_, doc)) = doc {
+ let mut doc = doc.borrow_mut();
+ let text = doc.text();
- if let Some(view) = view {
- let doc = view.doc.text();
let diagnostics = params
.diagnostics
.into_iter()
@@ -144,8 +145,8 @@ impl Application {
};
use helix_lsp::{lsp, util::lsp_pos_to_pos};
use lsp::DiagnosticSeverity;
- let start = lsp_pos_to_pos(doc, diagnostic.range.start);
- let end = lsp_pos_to_pos(doc, diagnostic.range.end);
+ let start = lsp_pos_to_pos(text, diagnostic.range.start);
+ let end = lsp_pos_to_pos(text, diagnostic.range.end);
Diagnostic {
range: Range { start, end },
@@ -165,8 +166,8 @@ impl Application {
})
.collect();
- view.doc.diagnostics = diagnostics;
-
+ doc.diagnostics = diagnostics;
+ drop(doc);
// TODO: we want to process all the events in queue, then render. publishDiagnostic tends to send a whole bunch of events
self.render();
}