aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-07 05:52:47 +0000
committerBlaž Hrastnik2021-05-07 05:52:47 +0000
commitc0a8b814870335986b595af25a10330bfe077793 (patch)
tree0389cc5462dd5ce51e6ce29d7b8d02e9f4e3dc4b
parentc20813690f962856efa1989576d9f7c91364f265 (diff)
Only send the document close event if we're closing the underlying buffer
-rw-r--r--helix-term/src/commands.rs4
-rw-r--r--helix-view/src/editor.rs30
2 files changed, 17 insertions, 17 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index addd7437..b7e853c4 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -856,7 +856,7 @@ pub fn command_mode(cx: &mut Context) {
match *parts.as_slice() {
["q"] | ["quit"] => {
- editor.close(editor.view().id);
+ editor.close(editor.view().id, /* close_buffer */ false);
}
["o", path] | ["open", path] => {
editor.open(path.into(), Action::Replace);
@@ -2085,7 +2085,7 @@ pub fn space_mode(cx: &mut Context) {
}
'c' => {
// close current split
- cx.editor.close(cx.view_id);
+ cx.editor.close(cx.view_id, /* close_buffer */ false);
}
// ' ' => toggle_alternate_buffer(cx),
// TODO: temporary since space mode took it's old key
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 435b2b7e..43311484 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -162,26 +162,26 @@ impl Editor {
Ok(id)
}
- pub fn close(&mut self, id: ViewId) {
+ pub fn close(&mut self, id: ViewId, close_buffer: bool) {
let view = self.tree.get(self.tree.focus);
- // get around borrowck issues
- let language_servers = &mut self.language_servers;
-
- let doc = &self.documents[view.doc];
+ // remove selection
+ self.documents[view.doc].selections.remove(&id);
- let language_server = doc
- .language
- .as_ref()
- .and_then(|language| language_servers.get(language));
+ if close_buffer {
+ // get around borrowck issues
+ let language_servers = &mut self.language_servers;
+ let doc = &self.documents[view.doc];
- if let Some(language_server) = language_server {
- tokio::spawn(language_server.text_document_did_close(doc.identifier()));
+ let language_server = doc
+ .language
+ .as_ref()
+ .and_then(|language| language_servers.get(language));
+ if let Some(language_server) = language_server {
+ tokio::spawn(language_server.text_document_did_close(doc.identifier()));
+ }
+ self.documents.remove(view.doc);
}
- // remove selection
- self.documents[view.doc].selections.remove(&id);
-
- // self.documents.remove(view.doc);
self.tree.remove(id);
self._refresh();
}