fix: retain the newest dictionary request

This commit is contained in:
2026-08-12 15:37:50 +09:00
parent fabce14933
commit 9c244d1dd1
4 changed files with 57 additions and 7 deletions

View File

@@ -135,7 +135,7 @@ reset(void)
void
dictsend(Im *im, Str *key)
{
Dictreq req;
Dictreq old, req;
req.key = *key;
req.lang = im->l->lang;
@@ -143,6 +143,9 @@ dictsend(Im *im, Str *key)
jpreading(im, &req.pre);
else
req.pre = im->pre;
/* imthread is the sole producer; discard every obsolete queued lookup. */
while(channbrecv(dictreqc, &old) > 0)
;
channbsend(dictreqc, &req);
}
@@ -271,7 +274,6 @@ static int
dotrans(Rune c, Str *com)
{
Emit e;
Dictreq req;
Str mapped;
if(isjp(&im))
@@ -297,10 +299,7 @@ dotrans(Rune c, Str *com)
sclear(&im.pre);
sappend(&im.pre, &e.next);
if(e.eat && e.dict.n > 0){
req.key = e.dict;
req.lang = im.l->lang;
req.pre = im.pre;
channbsend(dictreqc, &req);
dictsend(&im, &e.dict);
}
return e.eat;
}
@@ -626,7 +625,7 @@ keystroke(u32int ks, u32int mod, Str *com)
off = 0;
if(im.sel >= Maxdisp)
off = im.sel - Maxdisp + 1;
if(n >= 0 && n < Maxdisp && off + n < im.nkouho){
if(n >= 0 && n < Maxdisp && off + n < im.nkouho && mod == 0){
sappend(com, &im.kouho[off + n]);
reset();
return 1;