diff --git a/src/text_control.cpp b/src/text_control.cpp index dcf1a7e80f..707d29fcc0 100644 --- a/src/text_control.cpp +++ b/src/text_control.cpp @@ -515,8 +515,21 @@ void AnyTranslatableTextCtrl::SetLanguage(const Language& lang) #ifdef __WXOSX__ NSTextView *text = TextView(this); - [text setBaseWritingDirection:lang.IsRTL() ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight]; + if (lang.IsRTL()) + { + [text setBaseWritingDirection:NSWritingDirectionRightToLeft]; + if ([NSApp userInterfaceLayoutDirection] == NSUserInterfaceLayoutDirectionLeftToRight) + { + // extra nudge to make typing behave as expected: + [text makeTextWritingDirectionRightToLeft:nil]; + } + } + else + { + [text setBaseWritingDirection:NSWritingDirectionLeftToRight]; + } #endif + #ifdef __WXMSW__ BIDIOPTIONS bidi; ::ZeroMemory(&bidi, sizeof(bidi)); diff --git a/src/unicode_helpers.cpp b/src/unicode_helpers.cpp index 86501d5f48..2a5c44fcce 100644 --- a/src/unicode_helpers.cpp +++ b/src/unicode_helpers.cpp @@ -59,6 +59,14 @@ wxString strip_pointless_control_chars(const wxString& text, TextDirection dir) return text; const wchar_t first = *text.begin(); + const wchar_t last = *text.rbegin(); + + // POP DIRECTIONAL FORMATTING at the end is pointless (can happen on OS X + // when editing RTL text under LTR locale: + if (last == PDF) + { + return strip_pointless_control_chars(text.substr(0, text.size() - 1), dir); + } if (dir == TextDirection::LTR) {