diff options
-rw-r--r-- | buffer.c | 25 | ||||
-rw-r--r-- | lsp-write.c | 14 | ||||
-rw-r--r-- | lsp.h | 1 | ||||
-rw-r--r-- | main.c | 2 |
4 files changed, 21 insertions, 21 deletions
@@ -1901,14 +1901,13 @@ void buffer_apply_lsp_text_edits(TextBuffer *buffer, const LSPResponse *response free(edits); } -static void buffer_send_lsp_did_change(LSP *lsp, TextBuffer *buffer, BufferPos pos, - u32 nchars_deleted, String32 new_text) { +static void buffer_send_lsp_did_change(LSP *lsp, TextBuffer *buffer, LSPPosition pos, + LSPPosition end, String32 new_text) { if (!buffer_is_named_file(buffer)) return; // this isn't a named buffer so we can't send a didChange request. LSPRange range = {0}; - range.start = buffer_pos_to_lsp_position(buffer, pos); - BufferPos pos_end = buffer_pos_advance(buffer, pos, nchars_deleted); - range.end = buffer_pos_to_lsp_position(buffer, pos_end); + range.start = pos; + range.end = end; const char *document = buffer->path; if (lsp_has_incremental_sync_support(lsp)) { @@ -2084,9 +2083,10 @@ BufferPos buffer_insert_text_at_pos(TextBuffer *buffer, BufferPos pos, String32 // we need to do this *after* making the change to the buffer // because of how non-incremental syncing works. LSP *lsp = buffer_lsp(buffer); - if (lsp) - buffer_send_lsp_did_change(lsp, buffer, pos, 0, str_start); - + if (lsp) { + LSPPosition lsp_pos = buffer_pos_to_lsp_position(buffer, pos); + buffer_send_lsp_did_change(lsp, buffer, lsp_pos, lsp_pos, str_start); + } const EditInfo info = { .pos = pos, .end = b, @@ -2565,6 +2565,7 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_) u32 index = pos.index; Line *line = &buffer->lines[line_idx], *lines_end = &buffer->lines[buffer->nlines]; const BufferPos end_pos = buffer_pos_advance(buffer, pos, nchars); + const LSPPosition end_pos_lsp = buffer_pos_to_lsp_position(buffer, end_pos); if (nchars + index > line->len) { // delete rest of line @@ -2617,9 +2618,11 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_) // we need to do this *after* making the change to the buffer // because of how non-incremental syncing works. LSP *lsp = buffer_lsp(buffer); - if (lsp) - buffer_send_lsp_did_change(lsp, buffer, pos, deletion_len, (String32){0}); - + if (lsp) { + LSPPosition pos_lsp = buffer_pos_to_lsp_position(buffer, pos); + buffer_send_lsp_did_change(lsp, buffer, pos_lsp, end_pos_lsp, (String32){0}); + } + buffer_lines_modified(buffer, line_idx, line_idx); signature_help_retrigger(buffer->ted); diff --git a/lsp-write.c b/lsp-write.c index 974a845..e0beea2 100644 --- a/lsp-write.c +++ b/lsp-write.c @@ -330,13 +330,6 @@ static void message_writer_write_and_free(LSP *lsp, JSONWriter *o) { size_t header_size = strlen(header_str); char *content = &builder.str[max_header_size - header_size]; memcpy(content, header_str, header_size); - - #if LSP_SHOW_C2S - const int limit = 1000; - debug_println("%s%.*s%s%s",term_italics(stdout),limit,content, - strlen(content) > (size_t)limit ? "..." : "", - term_clear(stdout)); - #endif if (lsp->log) { fprintf(lsp->log, "LSP MESSAGE FROM CLIENT TO SERVER\n%s\n\n", content + header_size); @@ -356,6 +349,13 @@ static void message_writer_write_and_free(LSP *lsp, JSONWriter *o) { } str_builder_free(&builder); + + #if LSP_SHOW_C2S + const int limit = 1000; + debug_println("%s%.*s%s%s",term_bold(stdout),limit,content, + strlen(content) > (size_t)limit ? "..." : "", + term_clear(stdout)); + #endif } static void write_symbol_tag_support(JSONWriter *o) { @@ -922,4 +922,3 @@ void lsp_write_quit(void); #define LSP_SHOW_C2S 0 #endif // LSP_INTERNAL - @@ -1,6 +1,4 @@ /* -TODO: -- what's wrong with clangd diagnostics? FUTURE FEATURES: - autodetect indentation (tabs vs spaces) - custom file/build command associations |