summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-12-24 12:24:29 -0500
committerpommicket <pommicket@gmail.com>2022-12-24 12:24:29 -0500
commite1b3296d7ecae1bf1620f53714ec3ba5b31709d4 (patch)
treefbd3cf86c686a6116abce3b1b82046feb7afea07 /buffer.c
parenta6a06900bf7206dc86017bbb1895272ebfac5418 (diff)
LSP setting!
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/buffer.c b/buffer.c
index 831bf89..a8baa26 100644
--- a/buffer.c
+++ b/buffer.c
@@ -735,13 +735,16 @@ static void buffer_line_free(Line *line) {
// Free a buffer. Once a buffer is freed, you can call buffer_create on it again.
// Does not free the pointer `buffer` (buffer might not have even been allocated with malloc)
void buffer_free(TextBuffer *buffer) {
- LSP *lsp = buffer_lsp(buffer);
- if (lsp) {
- LSPRequest did_close = {.type = LSP_REQUEST_DID_CLOSE};
- did_close.data.close = (LSPRequestDidClose){
- .document = lsp_document_id(lsp, buffer->filename)
- };
- lsp_send_request(lsp, &did_close);
+ if (!buffer->ted->quit) { // don't send didClose on quit (calling buffer_lsp would actually create a LSP if this is called after destroying all the LSPs which isnt good)
+
+ LSP *lsp = buffer_lsp(buffer);
+ if (lsp) {
+ LSPRequest did_close = {.type = LSP_REQUEST_DID_CLOSE};
+ did_close.data.close = (LSPRequestDidClose){
+ .document = lsp_document_id(lsp, buffer->filename)
+ };
+ lsp_send_request(lsp, &did_close);
+ }
}
Line *lines = buffer->lines;