engine: reject stale dictionary results

This commit is contained in:
2026-08-14 18:43:12 +09:00
parent 76af1a022f
commit 9a3a92170e
7 changed files with 83 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ static int visible = 0;
static void *activeowner;
static int activecap;
static Caret caret;
static u32int dictseq;
static void dictqmap(Im*);
static void dictqjp(Im*);
static void backjp(Im*);
@@ -34,6 +35,7 @@ int nlang = nelem(langs);
static void
clearkouho(void)
{
dictseq++;
im.nkouho = 0;
im.sel = -1;
}
@@ -147,6 +149,7 @@ dictsend(Im *im, Str *key)
req.key = *key;
req.lang = im->l->lang;
req.seq = dictseq;
if(isjp(im))
jpreading(im, &req.pre);
else
@@ -453,6 +456,7 @@ searchlookup(int lang, Str *key, Dictres *res)
req.key = *key;
req.pre = req.key;
req.lang = lang;
req.seq = 0;
dictlookup(&req, res);
}
@@ -769,6 +773,7 @@ init(void)
memset(&caret, 0, sizeof caret);
activeowner = nil;
activecap = 0;
dictseq = 0;
visible = 0;
}
@@ -833,7 +838,7 @@ dictresult(Dictres *res)
Str pre;
impre(&pre);
if(search.lang || res->lang != im.l->lang ||
if(search.lang || res->seq != dictseq || res->lang != im.l->lang ||
scmp(&res->key, &pre) != 0)
return;
setkouho(res);