diff options
author | pommicket <pommicket@gmail.com> | 2023-08-05 00:13:49 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-05 00:13:49 -0400 |
commit | b3244ce71e137b4a259d78b7dc043beb2a5c2aa9 (patch) | |
tree | ada89ac58ed474c98a7a1baf0b194008ce5381d0 /ide-rename-symbol.c | |
parent | f16cf8cbb099896820f0bc19ba13e613847246c9 (diff) |
edit chaining for symbol rename
Diffstat (limited to 'ide-rename-symbol.c')
-rw-r--r-- | ide-rename-symbol.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/ide-rename-symbol.c b/ide-rename-symbol.c index d14b539..4df948e 100644 --- a/ide-rename-symbol.c +++ b/ide-rename-symbol.c @@ -58,6 +58,7 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { } if (perform_changes) { + arr_foreach_ptr(data->changes, LSPWorkspaceChange, change) { switch (change->type) { case LSP_CHANGE_EDIT: { @@ -66,6 +67,11 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { if (!ted_open_file(ted, path)) goto done; TextBuffer *buffer = ted_get_buffer_with_file(ted, path); + if (!buffer->will_chain_edits) { + // chain all edits together so they can be undone with one ctrl+z + buffer_start_edit_chain(buffer); + } + if (!buffer) { // this should never happen since we just // successfully opened it @@ -73,6 +79,7 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { goto done; } + 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); @@ -88,7 +95,16 @@ void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response) { break; } } - done:; + done: + + // end all edit chains in all buffers + // they're almost definitely all created by us + for (u16 i = 0; i < TED_MAX_BUFFERS; ++i) { + if (ted->buffers_used[i]) { + TextBuffer *buffer = &ted->buffers[i]; + buffer_end_edit_chain(buffer); + } + } } rename_symbol_clear(ted); |