Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix IME/CoreTextEditContext not being reset properly #4140

Merged
1 commit merged into from
Jan 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions src/cascadia/TerminalControl/TSFInputControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
{
if (_editContext != nullptr)
{
// _editContext.NotifyFocusLeave(); TODO GitHub #3645: Enabling causes IME to no longer show up, need to determine if required
_editContext.NotifyFocusLeave();
philnach marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -209,23 +209,16 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// only need to do work if the current buffer has text
if (!_inputBuffer.empty())
{
const auto hstr = to_hstring(_inputBuffer.c_str());

// call event handler with data handled by parent
_compositionCompletedHandlers(hstr);
_compositionCompletedHandlers(_inputBuffer);

// clear the buffer for next round
const auto bufferLength = gsl::narrow_cast<int32_t>(_inputBuffer.length());
_inputBuffer.clear();
_textBlock.Text(L"");

// tell the input server that we've cleared the buffer
CoreTextRange emptyTextRange;
emptyTextRange.StartCaretPosition = 0;
emptyTextRange.EndCaretPosition = 0;

// indicate text is now 0
_editContext.NotifyTextChanged(emptyTextRange, 0, emptyTextRange);
_editContext.NotifySelectionChanged(emptyTextRange);
_editContext.NotifyTextChanged({ 0, bufferLength }, 0, { 0, 0 });
philnach marked this conversation as resolved.
Show resolved Hide resolved

// hide the controls until composition starts again
_canvas.Visibility(Visibility::Collapsed);
Expand Down