Skip to content

Commit

Permalink
Send TSF input buffer starting from _activeTextStart to the end of th…
Browse files Browse the repository at this point in the history
…e buffer (#4836)

<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request
Emoji composition was only being shown one letter at a time. This is because of the way I expected `CoreTextTextUpdatingEventArgs.Range` to be provided to TSFInputControl during composition (for Chinese/Japanese IME). Emoji IME composition gives the `StartCaretPosition` as the same as `EndCaretPosition`, unlike how for Chinese/Japanese IME, `StartCaretPosition` is usually the start of the composition and `EndCaretPosition` is the latest character in the composition. The solution is to change the `_inputBuffer.substr()` call to simply grab all of the buffer starting from `_activeTextStart`. This way I can ensure that I grab all of the "active text", instead of trusting the given `args.Range` to tell me the active text.

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #4828
* [x] CLA signed.
* [x] Tests added/passed

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Chinese, Japanese, Korean, Emoji composition performed. Emoji selection through pointer also performed.
  • Loading branch information
leonMSFT authored Mar 9, 2020
1 parent e79a421 commit a34a957
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cascadia/TerminalControl/TSFInputControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,16 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
::base::ClampSub<size_t>(range.EndCaretPosition, range.StartCaretPosition),
incomingText);

// If we receive tabbed IME input like emoji, kaomojis, and symbols, send it to the terminal immediately.
// They aren't composition, so we don't want to wait for the user to start and finish a composition to send the text.
// Emojis/Kaomojis/Symbols chosen through the IME without starting composition
// will be sent straight through to the terminal.
if (!_inComposition)
{
_SendAndClearText();
}
else
{
Canvas().Visibility(Visibility::Visible);
const auto text = _inputBuffer.substr(range.StartCaretPosition, range.EndCaretPosition - range.StartCaretPosition + 1);
const auto text = _inputBuffer.substr(_activeTextStart);
TextBlock().Text(text);
}

Expand All @@ -338,7 +338,7 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
// - <none>
void TSFInputControl::_SendAndClearText()
{
const auto text = _inputBuffer.substr(_activeTextStart, _inputBuffer.length() - _activeTextStart);
const auto text = _inputBuffer.substr(_activeTextStart);

_compositionCompletedHandlers(text);

Expand Down

0 comments on commit a34a957

Please sign in to comment.