Skip to content

Commit b47fdfc

Browse files
authored
Fix support for the Tencent QQPinyin IME (#19046)
1 parent f28bb42 commit b47fdfc

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

.github/actions/spelling/allow/allow.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ dze
2424
dzhe
2525
Emacspeak
2626
Fitt
27-
FTCS
2827
flac
28+
FTCS
2929
gantt
3030
gfm
3131
ghe
@@ -61,8 +61,8 @@ Powerline
6161
ptys
6262
pwn
6363
pwshw
64-
QOL
6564
qof
65+
QOL
6666
qps
6767
quickfix
6868
rclt
@@ -82,6 +82,7 @@ stakeholders
8282
subpage
8383
sustainability
8484
sxn
85+
Tencent
8586
TLDR
8687
tonos
8788
toolset

src/tsf/Implementation.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -711,13 +711,28 @@ TextAttribute Implementation::_textAttributeFromAtom(TfGuidAtom atom) const
711711
TF_DISPLAYATTRIBUTE da;
712712
THROW_IF_FAILED(dai->GetAttributeInfo(&da));
713713

714-
if (da.crText.type != TF_CT_NONE)
715-
{
716-
attr.SetForeground(_colorFromDisplayAttribute(da.crText));
717-
}
718-
if (da.crBk.type != TF_CT_NONE)
719-
{
720-
attr.SetBackground(_colorFromDisplayAttribute(da.crBk));
714+
// The Tencent QQPinyin IME creates TF_CT_COLORREF attributes with a color of 0x000000 (black).
715+
// We respect their wish, which results in the preview text being invisible.
716+
// (Note that sending this COLORREF is incorrect, and not a bug in our handling.)
717+
//
718+
// After some discussion, we realized that an IME which sets only one color but not
719+
// the others is likely not properly tested anyway, so we reject those cases.
720+
// After all, what behavior do we expect, if the IME sends e.g. foreground=blue,
721+
// without knowing whether our terminal theme already uses a blue background?
722+
if (da.crText.type == da.crBk.type && da.crText.type == da.crLine.type)
723+
{
724+
if (da.crText.type != TF_CT_NONE)
725+
{
726+
attr.SetForeground(_colorFromDisplayAttribute(da.crText));
727+
}
728+
if (da.crBk.type != TF_CT_NONE)
729+
{
730+
attr.SetBackground(_colorFromDisplayAttribute(da.crBk));
731+
}
732+
if (da.crLine.type != TF_CT_NONE)
733+
{
734+
attr.SetUnderlineColor(_colorFromDisplayAttribute(da.crLine));
735+
}
721736
}
722737
if (da.lsStyle >= TF_LS_NONE && da.lsStyle <= TF_LS_SQUIGGLE)
723738
{
@@ -737,10 +752,6 @@ TextAttribute Implementation::_textAttributeFromAtom(TfGuidAtom atom) const
737752
{
738753
attr.SetUnderlineStyle(UnderlineStyle::DoublyUnderlined);
739754
}
740-
if (da.crLine.type != TF_CT_NONE)
741-
{
742-
attr.SetUnderlineColor(_colorFromDisplayAttribute(da.crLine));
743-
}
744755

745756
return attr;
746757
}

0 commit comments

Comments
 (0)