aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/StringUtil.cpp2
-rw-r--r--src/ui/controls/TextHostControlService.cpp1
-rw-r--r--src/win/gui/InputMethod.cpp10
3 files changed, 8 insertions, 5 deletions
diff --git a/src/common/StringUtil.cpp b/src/common/StringUtil.cpp
index b13c0193..0cadc545 100644
--- a/src/common/StringUtil.cpp
+++ b/src/common/StringUtil.cpp
@@ -255,7 +255,7 @@ gsl::index Utf16ForwardUntil(std::u16string_view str, gsl::index position,
UnreachableCode();
}
-inline bool IsSpace(CodePoint c) { return c == 0x20; }
+inline bool IsSpace(CodePoint c) { return c == 0x20 || c == 0xA; }
gsl::index Utf16PreviousWord(std::u16string_view str, gsl::index position,
bool* is_space) {
diff --git a/src/ui/controls/TextHostControlService.cpp b/src/ui/controls/TextHostControlService.cpp
index 502f63f9..07b4f1e8 100644
--- a/src/ui/controls/TextHostControlService.cpp
+++ b/src/ui/controls/TextHostControlService.cpp
@@ -346,7 +346,6 @@ void TextHostControlService::GainFocusHandler(
input_method_context_event_guard_ +=
input_method_context->TextEvent()->AddHandler(
[this](const std::u16string_view& text) {
- if (text == u"\b") return;
this->ReplaceSelectedText(text);
});
diff --git a/src/win/gui/InputMethod.cpp b/src/win/gui/InputMethod.cpp
index 6643ea58..cc237e88 100644
--- a/src/win/gui/InputMethod.cpp
+++ b/src/win/gui/InputMethod.cpp
@@ -226,7 +226,7 @@ void WinInputMethodContext::OnWindowNativeMessage(
const auto& message = args.GetWindowMessage();
switch (message.msg) {
case WM_CHAR: {
- const auto c = static_cast<char16_t>(message.w_param);
+ auto c = static_cast<char16_t>(message.w_param);
if (IsUtf16SurrogatePairCodeUnit(c)) {
// I don't think this will happen because normal key strike without ime
// should only trigger ascci character. If it is a charater from
@@ -235,8 +235,12 @@ void WinInputMethodContext::OnWindowNativeMessage(
u"A WM_CHAR message for character from supplementary "
u"planes is ignored.");
} else {
- char16_t s[1] = {c};
- text_event_.Raise({s, 1});
+ if (c != '\b') { // ignore backspace
+ if (c == '\r') c = '\n'; // Change \r to \n
+
+ char16_t s[1] = {c};
+ text_event_.Raise({s, 1});
+ }
}
args.HandleWithResult(0);
break;