From a8ecd337a1714653710d69a9fcaea8b354ffded8 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sat, 4 Mar 2023 16:12:41 -0500 Subject: regenerate tags if there are no completion results (if regenerate-tags-if-not-found is enabled) --- ide-autocomplete.c | 11 +++++++++-- main.c | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ide-autocomplete.c b/ide-autocomplete.c index 6d5716b..db9645c 100644 --- a/ide-autocomplete.c +++ b/ide-autocomplete.c @@ -384,12 +384,15 @@ void autocomplete_process_lsp_response(Ted *ted, const LSPResponse *response) { void autocomplete_open(Ted *ted, uint32_t trigger) { Autocomplete *ac = &ted->autocomplete; if (ac->open) return; - if (!ted->active_buffer) return; TextBuffer *buffer = ted->active_buffer; + if (!buffer) return; if (!buffer->path) return; if (buffer->view_only) return; autocomplete_clear_phantom(ac); + const Settings *settings = buffer_settings(buffer); + bool regenerated = false; + find_completions: ted->cursor_error_time = 0; ac->last_pos = (BufferPos){U32_MAX,0}; ac->cursor = 0; @@ -399,7 +402,11 @@ void autocomplete_open(Ted *ted, uint32_t trigger) { case 0: if (autocomplete_using_lsp(ted)) { ac->open = true; - } else { + } else if (settings->regenerate_tags_if_not_found && !regenerated) { + regenerated = true; + tags_generate(ted, false); + goto find_completions; + } else { autocomplete_no_suggestions(ted); } break; diff --git a/main.c b/main.c index f5c1dc5..0690f4d 100644 --- a/main.c +++ b/main.c @@ -5,7 +5,6 @@ FUTURE FEATURES: - better undo chaining (dechain on backspace?) - auto-reload config even for %included files - manual.md -- regenerate tags for completion too if there are no results - font setting & support for multiple fonts to cover more characters - support for variable-width fonts - robust find (results shouldn't move around when you type things) -- cgit v1.2.3