diff options
author | pommicket <pommicket@gmail.com> | 2023-08-05 00:09:23 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-05 00:09:23 -0400 |
commit | 692b91c5314bc6095428c7260257e8881ff8dbd5 (patch) | |
tree | 4cbaef0b892248ab81705f8edc5700bbcf5ec441 | |
parent | a6854a0ea52d1f614eeacecf0ec396d8d2cd3d32 (diff) |
basic renaming!
-rw-r--r-- | ide-rename-symbol.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ide-rename-symbol.c b/ide-rename-symbol.c index ee2f6e1..d14b539 100644 --- a/ide-rename-symbol.c +++ b/ide-rename-symbol.c @@ -59,11 +59,10 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { if (perform_changes) { arr_foreach_ptr(data->changes, LSPWorkspaceChange, change) { - printf("change type %u\n",change->type); switch (change->type) { case LSP_CHANGE_EDIT: { - LSPWorkspaceChangeEdit *edit = &change->data.edit; - const char *path = lsp_document_path(lsp, edit->document); + LSPWorkspaceChangeEdit *change_data = &change->data.edit; + const char *path = lsp_document_path(lsp, change_data->document); if (!ted_open_file(ted, path)) goto done; TextBuffer *buffer = ted_get_buffer_with_file(ted, path); @@ -73,7 +72,12 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { assert(0); goto done; } - printf("%s\n",path); + + LSPTextEdit *edit = &change_data->edit; + BufferPos start = buffer_pos_from_lsp(buffer, edit->range.start); + BufferPos end = buffer_pos_from_lsp(buffer, edit->range.end); + buffer_delete_chars_between(buffer, start, end); + buffer_insert_utf8_at_pos(buffer, start, lsp_response_string(response, edit->new_text)); } break; |