Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

fix: Problem with Japanease IME on macOS #57286

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,18 @@ - (void)insertText:(id)string replacementRange:(NSRange)range {

_activeModel->SetSelection(flutter::TextRange(base, extent));
}
else if (_activeModel->composing() && !(_activeModel->composing_range() == _activeModel->selection())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Please wrap this up to the previous line.

// When confirmed by Japanese IME, string replaces range of composing_range.
// If selection == composing_range there is no problem.
// If selection ! = composing_range the range of selection is only a part of composing_range.
// Since _activeModel->AddText is processed first for selection, the finalization of the conversion
// cannot be processed correctly unless selection == composing_range or selection.collapsed().
// Since _activeModel->SetSelection fails if (composing_ && !range.collapsed()),
// selection == composing_range will failed.
// Therefore, the selection cursor should only be placed at the beginning of composing_range.
flutter::TextRange composing_range = _activeModel->composing_range();
_activeModel->SetSelection(flutter::TextRange(composing_range.start()));
}

flutter::TextRange oldSelection = _activeModel->selection();
flutter::TextRange composingBeforeChange = _activeModel->composing_range();
Expand Down