summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index ad8363c..0cd5d29 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1370,6 +1370,12 @@ static Status buffer_insert_lines(TextBuffer *buffer, u32 where, u32 number) {
return false;
}
+static void buffer_send_lsp_did_change_request(LSP *lsp, TextBuffer *buffer, BufferPos pos,
+ u32 nchars_deleted, String32 new_text) {
+ // @TODO
+ abort();
+}
+
// inserts the given text, returning the position of the end of the text
BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32 str) {
buffer_pos_validate(buffer, &pos);
@@ -1404,6 +1410,10 @@ BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32
str32_remove_all_instances_of_char(&str, '\r');
+ LSP *lsp = buffer_lsp(buffer);
+ if (lsp)
+ buffer_send_lsp_did_change_request(lsp, buffer, pos, 0, str);
+
if (buffer->store_undo_events) {
BufferEdit *last_edit = arr_lastp(buffer->undo_history);
i64 where_in_last_edit = last_edit ? buffer_pos_diff(buffer, last_edit->pos, pos) : -1;
@@ -1650,6 +1660,10 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_)
// Not doing this might also cause other bugs, best to keep it here just in case.
nchars = (u32)buffer_get_text_at_pos(buffer, pos, NULL, nchars);
+ LSP *lsp = buffer_lsp(buffer);
+ if (lsp)
+ buffer_send_lsp_did_change_request(lsp, buffer, pos, nchars, (String32){0});
+
if (buffer->store_undo_events) {
// we need to make sure the undo history keeps track of the edit.
// we will either combine it with the previous BufferEdit, or create a new
@@ -2135,7 +2149,7 @@ Status buffer_load_file(TextBuffer *buffer, char const *filename) {
LSPRequest request = {.type = LSP_REQUEST_DID_OPEN};
LSPRequestDidOpen *open = &request.data.open;
open->file_contents = (char *)file_contents;
- open->path = str_dup(filename);
+ open->document = str_dup(filename);
open->language = buffer_language(buffer);
lsp_send_request(lsp, &request);
file_contents = NULL; // don't free