diff options
author | pommicket <pommicket@gmail.com> | 2022-12-20 12:25:18 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-20 12:25:18 -0500 |
commit | caf81c5a2c8b9432792c652edd0dcf1f64f7a4f1 (patch) | |
tree | dc1d327aff19b59b7fc636cce42d588e94c168ef /buffer.c | |
parent | 8deb7afed44d7be52cb450c3177ecc8e63fd46eb (diff) |
start didChange
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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 |