From: terencehill Date: Sat, 28 Sep 2024 00:54:20 +0000 (+0200) Subject: Autocompletion by # SHIFT-TAB: fix condition to detect # working even if there's... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f504ceea2482628aa9a6c0a7d79be9cdf53660e8;p=xonotic%2Fdarkplaces.git Autocompletion by # SHIFT-TAB: fix condition to detect # working even if there's a string between # and cursor --- 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; + } } } }