summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ide-rename-symbol.c18
-rw-r--r--main.c3
-rw-r--r--ted.h1
3 files changed, 18 insertions, 4 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);
diff --git a/main.c b/main.c
index 73e2213..16941bc 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,4 @@
/*
-TODO:
-- rename using LSP (textDocument/rename)
- - warn if many files are changing
FUTURE FEATURES:
- autodetect indentation (tabs vs spaces)
- robust find (results shouldn't move around when you type things)
diff --git a/ted.h b/ted.h
index 6b9ee2d..b8759d0 100644
--- a/ted.h
+++ b/ted.h
@@ -1555,6 +1555,7 @@ void hover_frame(Ted *ted, double dt);
// === ide-rename-symbol.c ===
void rename_symbol_clear(Ted *ted);
void rename_symbol_frame(Ted *ted);
+void rename_symbol_process_lsp_response(Ted *ted, LSPResponse *response);
// === ide-signature-help.c ===
/// figure out new signature help