Only send the document close event if we're closing the underlying buffer

pull/11/head
Blaž Hrastnik 4 years ago
parent c20813690f
commit c0a8b81487

@ -856,7 +856,7 @@ pub fn command_mode(cx: &mut Context) {
match *parts.as_slice() { match *parts.as_slice() {
["q"] | ["quit"] => { ["q"] | ["quit"] => {
editor.close(editor.view().id); editor.close(editor.view().id, /* close_buffer */ false);
} }
["o", path] | ["open", path] => { ["o", path] | ["open", path] => {
editor.open(path.into(), Action::Replace); editor.open(path.into(), Action::Replace);
@ -2085,7 +2085,7 @@ pub fn space_mode(cx: &mut Context) {
} }
'c' => { 'c' => {
// close current split // close current split
cx.editor.close(cx.view_id); cx.editor.close(cx.view_id, /* close_buffer */ false);
} }
// ' ' => toggle_alternate_buffer(cx), // ' ' => toggle_alternate_buffer(cx),
// TODO: temporary since space mode took it's old key // TODO: temporary since space mode took it's old key

@ -162,26 +162,26 @@ impl Editor {
Ok(id) 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); let view = self.tree.get(self.tree.focus);
// get around borrowck issues // remove selection
let language_servers = &mut self.language_servers; self.documents[view.doc].selections.remove(&id);
let doc = &self.documents[view.doc];
let language_server = doc if close_buffer {
.language // get around borrowck issues
.as_ref() let language_servers = &mut self.language_servers;
.and_then(|language| language_servers.get(language)); let doc = &self.documents[view.doc];
if let Some(language_server) = language_server { let language_server = doc
tokio::spawn(language_server.text_document_did_close(doc.identifier())); .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.tree.remove(id);
self._refresh(); self._refresh();
} }

Loading…
Cancel
Save