From f504ceea2482628aa9a6c0a7d79be9cdf53660e8 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 28 Sep 2024 02:54:20 +0200 Subject: [PATCH] Autocompletion by # SHIFT-TAB: fix condition to detect # working even if there's a string between # and cursor --- console.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/console.c b/console.c index 22ba40fe..9acfe146 100644 --- a/console.c +++ b/console.c @@ -2578,20 +2578,23 @@ static int Nicks_CompleteCountPossible(char *line, int pos, char *s, qbool isCon { if(line[spos] == '#') { - int len = (int) strspn(line+spos+1, "0123456789"); // number of digits - if (len == 0) + if (line[spos + 1] == 0) { if (p == hash_completion_player) match = spos; } else { - hash_completion_player = -1; - if (line[pos-1] == ' ') - ++len; - // word lenght EQUAL digits count OR digits count + 1 trailing space - if(((pos)-(spos+1)) == len && p == (atoi(line+spos+1)-1)) - match = spos; + int len = (int) strspn(line+spos+1, "0123456789"); // number of digits + if (len > 0) + { + hash_completion_player = -1; + if (line[pos-1] == ' ') + ++len; + // word lenght EQUAL digits count OR digits count + 1 trailing space + if(((pos)-(spos+1)) == len && p == (atoi(line+spos+1)-1)) + match = spos; + } } } } -- 2.39.2