aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-16 07:20:43 +0000
committerBlaž Hrastnik2021-03-16 07:27:12 +0000
commit54a7e893b704b268f7d9d8b4692d3722db6a98df (patch)
tree1400fdc10f813725a1648b08236b4ec401f237b4
parenteca2a73ad0e829dbd83da8f42a8a2bd5c17bbf75 (diff)
lsp: Wire up didClose notification on editor.close.
-rw-r--r--helix-term/src/commands.rs2
-rw-r--r--helix-view/src/editor.rs18
2 files changed, 17 insertions, 3 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d80662d7..353d79cc 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -691,7 +691,7 @@ pub fn command_mode(cx: &mut Context) {
match *parts.as_slice() {
["q"] | ["quit"] => {
- editor.tree.remove(editor.view().id);
+ editor.close(editor.view().id, executor);
// editor.should_close = true,
}
["o", path] | ["open", path] => {
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 0dd0592c..b04a07dd 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -48,7 +48,7 @@ impl Editor {
let language_id = doc
.language()
- .and_then(|s| s.split(".").last()) // source.rust
+ .and_then(|s| s.split('.').last()) // source.rust
.map(ToOwned::to_owned)
.unwrap_or_default();
@@ -66,7 +66,21 @@ impl Editor {
Ok(())
}
- pub fn close(&mut self, id: Key) {
+ pub fn close(&mut self, id: Key, executor: &smol::Executor) {
+ let view = self.tree.get(self.tree.focus);
+ // get around borrowck issues
+ let language_servers = &mut self.language_servers;
+
+ let doc = &view.doc;
+
+ let language_server = doc
+ .language
+ .as_ref()
+ .and_then(|language| language_servers.get(language, &executor));
+
+ if let Some(language_server) = language_server {
+ smol::block_on(language_server.text_document_did_close(doc.identifier())).unwrap();
+ }
self.tree.remove(id)
}