diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | control | 2 | ||||
-rw-r--r-- | ide-autocomplete.c | 32 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | ted.h | 2 |
5 files changed, 26 insertions, 13 deletions
@@ -318,6 +318,7 @@ Then, open windows\_installer\\ted\\ted.sln, and build. <tr><td>2.2r1</td> <td>Minor bug fixes</td> <td>2023 Mar 27</td></tr> <tr><td>2.3</td> <td>`:matching-bracket`, various minor improvements</td> <td>2023 May 11</td></tr> <tr><td>2.3.1</td> <td>Bugfixes, better undo chaining, highlight TODOs in comments.</td> <td>2023 May 22</td></tr> +<tr><td>2.3.2</td> <td>Misc bugfixes</td> <td>2023 Jun 17</td></tr> </table> ## License @@ -1,5 +1,5 @@ Package: ted -Version: 2.3.1 +Version: 2.3.2 Section: text Priority: optional Architecture: amd64 diff --git a/ide-autocomplete.c b/ide-autocomplete.c index 3d5e24c..b8898d5 100644 --- a/ide-autocomplete.c +++ b/ide-autocomplete.c @@ -322,7 +322,10 @@ void autocomplete_process_lsp_response(Ted *ted, const LSPResponse *response) { for (size_t i = 0; i < ncompletions; ++i) { const LSPCompletionItem *lsp_completion = &completion->items[i]; const char *new_text = lsp_response_string(response, lsp_completion->text_edit.new_text); - if (str_has_prefix(new_text, word_at_cursor)) { + if (str_has_prefix(new_text, word_at_cursor) && ( + // ignore completions with duplicate text + !candidate || !streq(candidate, new_text) + )) { candidate = new_text; ++ncandidates; if (ncandidates >= 2) break; @@ -398,8 +401,8 @@ void autocomplete_open(Ted *ted, uint32_t trigger) { ac->cursor = 0; autocomplete_find_completions(ted, trigger, false); - switch (arr_len(ac->completions)) { - case 0: + + if (arr_len(ac->completions) == 0) { if (autocomplete_using_lsp(ted)) { ac->open = true; } else if (settings->regenerate_tags_if_not_found && !regenerated) { @@ -409,16 +412,25 @@ void autocomplete_open(Ted *ted, uint32_t trigger) { } else { autocomplete_no_suggestions(ted); } - break; - case 1: + return; + } + + bool multiple_completions = false; + for (u32 i = 1; i < arr_len(ac->completions); ++i) { + if (!streq(ac->completions[i].text, ac->completions[0].text)) { + multiple_completions = true; + break; + } + } + + if (!multiple_completions) { autocomplete_complete(ted, ac->completions[0]); // (^ this calls autocomplete_close) - break; - default: - // open autocomplete menu - ac->open = true; - break; + return; } + + // open autocomplete menu + ac->open = true; } static void autocomplete_find_phantom(Ted *ted) { @@ -1,6 +1,5 @@ /* TODO: -- select sole completion if all completions' textEdits are identical (e.g. SyntaxCharT___ in ted) FUTURE FEATURES: - autodetect indentation (tabs vs spaces) - font setting & support for multiple fonts to cover more characters @@ -131,6 +130,7 @@ static void error_signal_handler(int signum, siginfo_t *info, void *context) { Ted *ted = error_signal_handler_ted; if (ted) { FILE *log = ted->log; + if (log) { fprintf(log, "Signal %d: %s\n", signum, strsignal(signum)); fprintf(log, "errno = %d\n", info->si_errno); @@ -28,7 +28,7 @@ extern "C" { #include "sdl-inc.h" /// Version number -#define TED_VERSION "2.3.1" +#define TED_VERSION "2.3.2" /// Version string #define TED_VERSION_FULL "ted v. " TED_VERSION /// Maximum path size ted handles. |