Skip to content

Commit

Permalink
Fix issues with Japanese & Vietnamese IME
Browse files Browse the repository at this point in the history
  • Loading branch information
lhecker committed Aug 4, 2022
1 parent e158d89 commit 09fcd4b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
7 changes: 4 additions & 3 deletions .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ antialias
antialiasing
ANull
anycpu
AOn
APARTMENTTHREADED
APCs
api
Expand Down Expand Up @@ -80,7 +79,6 @@ ASingle
asm
asmv
asmx
AStomps
ASYNCWINDOWPOS
atch
ATest
Expand Down Expand Up @@ -225,14 +223,14 @@ CFuzz
cgscrn
chafa
changelist
chaof
charinfo
charset
CHARSETINFO
chcp
checkbox
checkboxes
chh
Childitem
chk
chrono
CHT
Expand Down Expand Up @@ -2756,6 +2754,9 @@ xes
xff
XFile
XFORM
xin
xinchaof
xinxinchaof
XManifest
XMath
XMFLOAT
Expand Down
2 changes: 0 additions & 2 deletions src/cascadia/TerminalControl/TSFInputControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_inputBuffer.clear();
_selection = {};
_activeTextStart = 0;
_editContext.NotifyFocusLeave();
_editContext.NotifyTextChanged({ 0, INT32_MAX }, 0, _selection);
_editContext.NotifyFocusEnter();
TextBlock().Text({});
}
}
Expand Down
19 changes: 13 additions & 6 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,19 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return;
}

// GH#11479: TSF wants to be notified of any character input via ICoreTextEditContext::NotifyTextChanged().
// TSF is built and tested around the idea that you inform it of any text changes that happen
// when it doesn't currently compose characters. For instance writing "xin chaof" with the
// Vietnamese IME should produce "xin chào". After writing "xin" it'll emit a composition
// completion event and we'll write "xin" to the shell. It now has no input focus and won't know
// about the whitespace. If you then write "chaof", it'll emit another composition completion
// event for "xinchaof" and the resulting output in the shell will finally read "xinxinchaof".
// A composition completion event technically doesn't mean that the completed text is now
// immutable after all. We could (and probably should) inform TSF of any input changes,
// but we technically aren't a text input field. The immediate solution was
// to simply force TSF to clear its text whenever we have input focus.
TSFInputControl().ClearBuffer();

_HidePointerCursorHandlers(*this, nullptr);

const auto ch = e.Character();
Expand Down Expand Up @@ -1182,12 +1195,6 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
const auto window = CoreWindow::GetForCurrentThread();

if (vkey == VK_ESCAPE ||
vkey == VK_RETURN)
{
TSFInputControl().ClearBuffer();
}

// If the terminal translated the key, mark the event as handled.
// This will prevent the system from trying to get the character out
// of it and sending us a CharacterReceived event.
Expand Down

0 comments on commit 09fcd4b

Please sign in to comment.