From 85c30e8fb21170d602efb53a86c0000a3aa79cbf Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 17 Oct 2023 20:01:15 -0400 Subject: switch back to starting file after rename --- ide-rename-symbol.c | 17 ++++++++--------- main.c | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ide-rename-symbol.c b/ide-rename-symbol.c index e5e30fb..a379d1d 100644 --- a/ide-rename-symbol.c +++ b/ide-rename-symbol.c @@ -118,19 +118,22 @@ void rename_symbol_process_lsp_response(Ted *ted, const LSPResponse *response) { || response->request.id != rs->request_id.id) { return; } - - const LSPResponseRename *data = &response->data.rename; LSP *lsp = ted_get_lsp_by_id(ted, rs->request_id.lsp); + + if (menu_is_open(ted, MENU_RENAME_SYMBOL)) + menu_close(ted); + const LSPResponseRename *data = &response->data.rename; if (!lsp) { // LSP crashed or something - goto cleanup; + return; } + TextBuffer *const start_buffer = ted_active_buffer(ted); arr_foreach_ptr(data->changes, const LSPWorkspaceChange, change) { if (change->type == LSP_CHANGE_DELETE && change->data.delete.recursive) { ted_error(ted, "refusing to perform rename because it involves a recursive deletion\n" "I'm too scared to go through with this"); - goto cleanup; + return; } } @@ -202,11 +205,7 @@ void rename_symbol_process_lsp_response(Ted *ted, const LSPResponse *response) { ted_save_all(ted); } - - cleanup: - rename_symbol_clear(ted); - if (menu_is_open(ted, MENU_RENAME_SYMBOL)) - menu_close(ted); + ted_switch_to_buffer(ted, start_buffer); } void rename_symbol_init(Ted *ted) { diff --git a/main.c b/main.c index 78b3373..81bd118 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,5 @@ /* TODO: -- switch back to starting file after rename - .editorconfig (see https://editorconfig.org/) FUTURE FEATURES: - autodetect indentation (tabs vs spaces) -- cgit v1.2.3